Network Deployment (Distributed operating systems), v8.0 > Develop and deploying applications > Develop Dynamic and EJB query > Develop applications that use EJB query > EJB query language
Path expressions
A path expression is an identification variable followed by the navigation operator ( . ) and a container managed persistence (CMP) or relationship name.
A path expression that leads to a cmr field can be further navigated if the cmr field is single-valued. If the path expression leads to a multi-valued relationship, then the path expression is terminal and cannot be further navigated. If the path expression leads to a CMP field whose type is a value object, it is possible to navigate to attributes of the value object.
Example: Value object
Assume that address is a CMP field for EmpBean, which is a value object.
SELECT object(e) FROM EmpBean e WHERE e.address.distance('San Jose') < 10 and e.address.zip = 95037It is best to use the composer pattern to map value object attributes to relational columns if you intend to search on value attributes. If you store value objects in serialized format, then each value object must be retrieved from the database and deserialized. Value object methods can only be done in dynamic queries.
A path expression can also navigate to a bean method. The method must be defined on either the remote or local bean interface. Methods can only be used in dynamic queries. We cannot mix both remote and local methods in a single query statement.
If the query contains remote methods, the dynamic query must be executed using the query remote interface. Using the query remote interface causes the query service to activate beans and create instances of the remote bean interface
Likewise, a query statement with local bean methods must be executed with the query local interface. This causes the query service to activate beans and local interface instances.
Do not use get methods to access CMP and cmr fields of a bean.
If a method has overloaded definitions, the overloaded methods must have different number of parameters.
Methods must have non-void return types and method arguments and return types must be either primitive types byte, short, int, long, float, double, boolean, char or wrapper types from the following list:
Byte, Short, Integer, Long, Float, Double, BigDecimal, String, Boolean, Character, java.util.Calendar, java.sql.Date, java.sql.Time, java.sql.Timestamp, java.util.Date
If any input argument to a method is NULL, it is assumed the method returns a NULL value and the method is not invoked.
A collection valued path expression can be used in the FROM clause as a collection member declaration, and with the IS EMPTY, MEMBER OF, and EXISTS predicates in the WHERE clause.
FROM clause usage. The following table lists three valid From clause usage and one invalid usage.
FROM clause usage statement Validity statement FROM EmpBean e WHERE e.dept.mgr.name='Bob'OK FROM EmpBean e WHERE e.dept.emps.name='BOB'INVALID -- cannot navigate through emps because it is multivalued FROM EmpBean e, IN (e.dept.emps) e1 WHERE e1.name='BOB'OK FROM EmpBean e WHERE e.dept.emps IS EMPTYOK
EJB query language
Use EJB query
Use the dynamic query service