Oracle® Containers for J2EE Enterprise JavaBeans Developer's Guide 10g (10.1.3.1.0) Part Number B28221-02 |
|
|
View PDF |
Although EJB 2.1 does not support square root, date, time, and timestamp types, OC4J provides proprietary EJB QL extensions to support these types in EJB 2.1, as follows:
SQRT
(v): Both the double primitive type and the java.lang.Double
types are supported for arguments (see Example 16-5).
You can use the following date, time, and timestamp types in an EJB QL binary expression, such as the following equality expressions:
java.util.Date
(see Example 16-6
java.sql.Date
(see Example 16-7)
java.sql.Time
(see Example 16-8)
java.sql.Timestamp
(see Example 16-9)
Note:
These types are fully supported in EJB 3.0 EJB QL.Example 16-5 Using the EJB 2.1 EJB QL Extension for SQRT
<query> <query-method> <method-name>ejbSelectDoubleTypeSqrt</method-name> <method-params> <method-param>double</method-param> </method-params> </query-method> <result-type-mapping>Remote</result-type-mapping> <ejb-ql> SELECT OBJECT(a) FROM Dept a WHERE a.deptDoubleType = SQRT(?1) </ejb-ql> </query>
Example 16-6 Using the EJB 2.1 EJB QL Extension for java.util.Date
<query>
<query-method>
<method-name>ejbSelectDate</method-name>
<method-params>
<method-param>java.util.Date</method-param>
</method-params>
</query-method>
<result-type-mapping>Remote</result-type-mapping>
<ejb-ql>
SELECT OBJECT(a) FROM Dept a WHERE a.deptDate = ?1
</ejb-ql>
</query>
Example 16-7 Using the EJB 2.1 EJB QL Extension for java.sql.Date
<query>
<query-method>
<method-name>ejbSelectSqlDate</method-name>
<method-params>
<method-param>java.sql.Date</method-param>
</method-params>
</query-method>
<result-type-mapping>Remote</result-type-mapping>
<ejb-ql>
SELECT OBJECT(a) FROM Dept a WHERE a.deptSqlDate = ?1
</ejb-ql>
</query>
Example 16-8 Using the EJB 2.1 EJB QL Extension for java.sql.Time
<query>
<query-method>
<method-name>findByTimestamp</method-name>
<method-params>
<method-param>java.sql.Time</method-param>
</method-params>
</query-method>
<result-type-mapping>Remote</result-type-mapping>
<ejb-ql>
SELECT OBJECT(a) FROM Dept a WHERE a.deptTime = ?1
</ejb-ql>
</query>
Example 16-9 Using the EJB 2.1 EJB QL Extension for java.sql.Timestamp
<query>
<query-method>
<method-name>findByTimestamp</method-name>
<method-params>
<method-param>java.sql.Timestamp</method-param>
</method-params>
</query-method>
<result-type-mapping>Remote</result-type-mapping>
<ejb-ql>
SELECT OBJECT(a) FROM Dept a WHERE a.deptTimestamp = ?1
</ejb-ql>
</query>