web server - Borland Technical Publications

web server - Borland Technical Publications web server - Borland Technical Publications

techpubs.borland.com
from techpubs.borland.com More from this publisher
12.11.2014 Views

Setting Properties Table 14.1 Navigation Tree Node/ Descriptor Element Panel Name DDEditor Tab Environment Entries Bean Environment EJB References to other Beans Bean EJB References EJB Links Bean EJB References Resource References to data Bean Resource References objects/connection factories Resource Reference type Bean Resource References Resource Reference Bean Resource References Authentication Type Security Role References Bean Security Role References Entity Properties Bean Properties Container Transactions Bean:Container Container Transactions Transactions Transactional Method Bean:Container Container Transactions Transactions Transactional Method Interface Bean:Container Container Transactions Transactions Transactional Attribute Bean:Container Container Transactions Transactions Method Permissions Bean:Method Permissions Method Permissions CMP Description Bean:CMP1.1 CMP 1.1 CMP Tables Bean:CMP1.1 CMP 1.1 Container-Managed Fields Bean:CMP1.1 CMP 1.1 Description Finders Bean:CMP1.1 Finders Finder Method Bean:CMP1.1 Finders Finder WHERE Clause Bean:CMP1.1 Finders Finder Load State option Bean:CMP1.1 Finders Container-managed data access support For container-managed persistence, the Borland EJB Container supports all data types supported by the JDBC specification, plus some other types beyond those supported by JDBC. The following table shows the basic and complex types supported by the Borland EJB Container: Basic types: boolean Boolean byte Byte char Character double Double float Float int Integer long Long short Short String java.sql.Date Complex types: J2EE 1.2 Entity Bean using BMP or CMP 1.1 (continued) BigDecimal java.util.Date byte[] java.sql.Time java.sql.TimeStamp Any class implementing java.io.Serializable, such as Vector and Hashtable Other entity bean references Keep in mind that the Borland Container supports classes implementing the java.io.Serializable interface, such as Hashtable and Vector. The container supports other data types, such as Java collections or third party collections, because they also implement java.io.Serializable. For classes and data types that implement the Serializable interface, the Container merely serializes their state and stores the result Chapter 14: Entity Beans and CMP 1.1 in Borland Enterprise Server 121

Setting Properties into a BLOB. The Container does not do any “smart” mapping on these classes or types; it just stores the state in binary format. The Container's CMP engine observes the following rule: the engine serializes as a BLOB all types that are not one of the explicitly supported types. In this context, the Container follows the JDBC specification: a BLOB is the type to which LONGVARBINARY maps. (For Oracle, this is LONG RAW.) Using SQL keywords The CMP engine for the Borland Container can handle all SQL keywords that comply with the SQL92 standard. However, you should keep in mind that vendors frequently add their own keywords. For example, Oracle uses the keyword VARCHAR2. If you want to ensure that the CMP engine can handle vendor keywords that may differ from the SQL standard, set up an environment property in the deployment descriptor that maps the CMP field name to the column name. By using this sort of environment property, you do not have to modify your code. For example, suppose you have a CMP field called “select”. You can use the following environment property to map “select” to a column called “SLCT”, as shown below. Data select SLCT Using null values It is possible that your database values can contain SQL null values. If so, you must map them to fields whose Java data types are permitted to contain Java null values. Typically, you do this by using Java types instead of primitive types. Thus, you use a Java Integer type rather than a primitive int type, or a Java Float type rather than a primitive float type. Establishing a database connection You must specify a DataSource so that the CMP engine can open a database connection. The DataSource defines the information necessary for establishing a database connection, such as username and password. Define a DataSource and then use a resource-ref to refer to the DataSource in the XML deployment descriptor for the bean. The CMP engine can then use the DataSource to access the database via JDBC. At the point in the vendor-specific XML file where you provide the jndi binding for the resource-ref, add the element True For cases where the entity bean declares only one resource-ref, you do not need to provide the above XML element. When the entity bean has only one resource-ref, the Borland Container knows to automatically choose that one resource as the cmpresource. Container-created tables You can instruct the Borland EJB Container to automatically create tables for container-managed entities based on the entity's container-managed fields. Because table creation and data type mappings vary among vendors, you must specify the JDBC database dialect in the deployment descriptor to the Container. For all 122 BES Developer’s Guide

Setting Properties<br />

Table 14.1<br />

Navigation Tree Node/<br />

Descriptor Element<br />

Panel Name<br />

DDEditor Tab<br />

Environment Entries Bean Environment<br />

EJB References to other Beans Bean EJB References<br />

EJB Links Bean EJB References<br />

Resource References to data Bean<br />

Resource References<br />

objects/connection factories<br />

Resource Reference type Bean Resource References<br />

Resource Reference<br />

Bean<br />

Resource References<br />

Authentication Type<br />

Security Role References Bean Security Role References<br />

Entity Properties Bean Properties<br />

Container Transactions<br />

Bean:Container<br />

Container Transactions<br />

Transactions<br />

Transactional Method<br />

Bean:Container<br />

Container Transactions<br />

Transactions<br />

Transactional Method Interface Bean:Container<br />

Container Transactions<br />

Transactions<br />

Transactional Attribute<br />

Bean:Container<br />

Container Transactions<br />

Transactions<br />

Method Permissions Bean:Method Permissions Method Permissions<br />

CMP Description Bean:CMP1.1 CMP 1.1<br />

CMP Tables Bean:CMP1.1 CMP 1.1<br />

Container-Managed Fields<br />

Bean:CMP1.1 CMP 1.1<br />

Description<br />

Finders Bean:CMP1.1 Finders<br />

Finder Method Bean:CMP1.1 Finders<br />

Finder WHERE Clause Bean:CMP1.1 Finders<br />

Finder Load State option Bean:CMP1.1 Finders<br />

Container-managed data access support<br />

For container-managed persistence, the <strong>Borland</strong> EJB Container supports all data types<br />

supported by the JDBC specification, plus some other types beyond those supported<br />

by JDBC.<br />

The following table shows the basic and complex types supported by the <strong>Borland</strong> EJB<br />

Container:<br />

Basic types: boolean Boolean byte Byte char Character<br />

double Double float Float int Integer<br />

long Long short Short String java.sql.Date<br />

Complex types:<br />

J2EE 1.2 Entity Bean using BMP or CMP 1.1 (continued)<br />

BigDecimal<br />

java.util.Date<br />

byte[]<br />

java.sql.Time<br />

java.sql.TimeStamp<br />

Any class implementing java.io.Serializable, such as Vector and<br />

Hashtable<br />

Other entity bean references<br />

Keep in mind that the <strong>Borland</strong> Container supports classes implementing the<br />

java.io.Serializable interface, such as Hashtable and Vector. The container supports<br />

other data types, such as Java collections or third party collections, because they also<br />

implement java.io.Serializable. For classes and data types that implement the<br />

Serializable interface, the Container merely serializes their state and stores the result<br />

Chapter 14: Entity Beans and CMP 1.1 in <strong>Borland</strong> Enterprise Server 121

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!