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

Container-managed data access support Important Note Important You specify your own optimized SQL in the Borland proprietary deployment descriptor, ejb-borland.xml. The XML grammar is identical to that found in ejb-jar.xml, except that the element is replaced with a element. This proprietary element contains a SQL-92 statement (not an EJB-QL statement) that is used to access the database instead of the CMP engine-generated SQL. The SELECT clause for this statement must be identical to the SELECT clause generated by the Borland CMP engine. Subsequent clauses are user-optimized. The ordering of the fields in the SELECT clause is proprietary to the CMP engine and therefore must be preserved. For example: EmployeeBean ... findWealthyEmployees SELECT E.DEPT_NO, E.EMP_NO, E.FIRST_NAME, E.FULL_NAME, E.HIRE_DATE, E.JOB_CODE, E.JOB_COUNTRY, E.JOB_GRADE, E.LAST_NAME, E.PHONE_EXT, E.SALARY FROM EMPLOYEE E WHERE E.SALARY > 200000 ... The extensive SELECT statement reflects the type of SQL generated by the CMP engine. When the CMP engine encounters an EJB-QL statement in the ejb-jar.xml deployment descriptor, it checks ejb-borland.xml to see if there is any user SQL provided in the same bean's descriptor. If none is present, the CMP engine generates its own SQL and executes it. If the ejb-borland.xml descriptor does contain a query element, it uses the SQL within the tags instead. The element in ejb-borland.xml does not replace the element in the standard ejb-jar.xml deployment descriptor. If you want to override the CMP engine's SQL, you must provide the elements in both descriptors. Container-managed data access support For CMP, the Borland EJB Container supports all data types supported by the JDBC specification, including 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 BigDecimal java.util.Date byte[] java.sql.Time java.sql.TimeStamp Chapter 17: EJB-QL and Data Access Support 159

Container-managed data access support Complex types: Any class implementing java.io.Serializable, such as Vector and Hashtable Other entity bean references Note The Borland CMP engine now supports using the Long value type for dates, as well as java.sql.Date for java.util.Date. 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 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. Depending on your database implementation, the following data types require fetching based on column index: Database Data Types Oracle ■ LONG RAW Sybase ■ NTEXT ■ IMAGE MS SQL ■ NTEXT ■ IMAGE Note If you use either of the two data types BINARY (MS SQL) or RAW (Oracle) as primary keys, you must explicitly specify their size. Support for Oracle Large Objects (LOBs) There are two types of Large Objects (LOBs), Binary Large Objects (BLOBs) and Character Large Objects (CLOBs). BLOBs are mapped to CMP fields with the following data types: ■ byte[] ■ java.io.Serializable ■ java.io.InputStream CLOBs, by virtue of being Character Large Objects, can only be mapped to cmp-fields with the java.lang.String data type. 160 BES Developer’s Guide

Container-managed data access support<br />

Complex types:<br />

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

Hashtable<br />

Other entity bean references<br />

Note<br />

The <strong>Borland</strong> CMP engine now supports using the Long value type for dates, as well as<br />

java.sql.Date for java.util.Date.<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 />

into a BLOB. The Container does not do any “smart” mapping on these classes or types;<br />

it just stores the state in binary format. The Container's CMP engine observes the<br />

following rule: the engine serializes as a BLOB all types that are not one of the explicitly<br />

supported types.<br />

Depending on your database implementation, the following data types require fetching<br />

based on column index:<br />

Database<br />

Data Types<br />

Oracle ■ LONG RAW<br />

Sybase ■ NTEXT<br />

■<br />

IMAGE<br />

MS SQL ■ NTEXT<br />

■<br />

IMAGE<br />

Note<br />

If you use either of the two data types BINARY (MS SQL) or RAW (Oracle) as primary keys,<br />

you must explicitly specify their size.<br />

Support for Oracle Large Objects (LOBs)<br />

There are two types of Large Objects (LOBs), Binary Large Objects (BLOBs) and<br />

Character Large Objects (CLOBs).<br />

BLOBs are mapped to CMP fields with the following data types:<br />

■<br />

byte[]<br />

■<br />

java.io.Serializable<br />

■<br />

java.io.InputStream<br />

CLOBs, by virtue of being Character Large Objects, can only be mapped to cmp-fields<br />

with the java.lang.String data type.<br />

160 BES Developer’s Guide

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

Saved successfully!

Ooh no, something went wrong!