How to migrate your application from JBoss v2.4 to JOnAS v3.0 | ||
---|---|---|
Prev | Chapter 2. Migrating your deployment descriptors | Next |
JBoss automatically generates the following finders if they are declared in the Home interface:
findAll()
findByPrimaryKey(primaryKey)
findByFieldName(fieldValue) where FieldName is the name of a field in your bean.
JOnAS does not automatically generate these finders so you will have to declare them in jonas-ejb-jar.xml. Here is an example of the declaration of these finders as they should be in JOnAS. The bean Region has a field id that matches its primary key and a field name which is the name of the region.
<jonas-ejb-jar> <jonas-entity> <ejb-name>Region</ejb-name> <jdbc-mapping> <finder-method-jdbc-mapping> <jonas-method> <method-name>findByPrimaryKey</method-name> </jonas-method> <jdbc-where-clause>where id=?</jdbc-where-clause> </finder-method-jdbc-mapping> <finder-method-jdbc-mapping> <jonas-method> <method-name>findByName</method-name> </jonas-method> <jdbc-where-clause>where name=?</jdbc-where-clause> </finder-method-jdbc-mapping> <finder-method-jdbc-mapping> <jonas-method> <method-name>findAll</method-name> </jonas-method> <jdbc-where-clause></jdbc-where-clause> </finder-method-jdbc-mapping> </jdbc-mapping> </jonas-entity> </jonas-ejb-jar>
With JBoss you have to declare customized finders in jaws.xml. You will also have to move these finders in the jonas-ejb-jar.xml file. Note that there is a slight syntax difference between JBoss and JOnAS regarding unknown values in queries. You don't have to number the parameters with JOnAS. Example of a customized finder declaration in JBoss:
<jaws> <finder> <name>findUserCurrentSellings</name> <query> items.seller={0} AND items.end_date>=NOW() </query> <order></order> </finder> </jaws>
This finder should be written this way with JOnAS:
<jonas-ejb-jar> <finder-method-jdbc-mapping> <jonas-method> <method-name>findUserCurrentSellings</method-name> </jonas-method> <jdbc-where-clause> WHERE items.seller=? AND items.end_date>=NOW() </jdbc-where-clause> </finder-method-jdbc-mapping> </jonas-ejb-jar>