How to migrate your application from JBoss v3.X to JOnAS v3.X | ||
---|---|---|
<<< Previous | 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 can only automatically generate the findByPrimaryKey method so you will have to declare the other find methods in jonas-ejb-jar.xml for CMP1.X or in ejb-jar.xml for CMP2.X. Here is an CMP1.1 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>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 or ejb-jar.xml following the different CMP versions. You will also have to move these finders in the jonas-ejb-jar.xml file or ejb-jar.xml. 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. Here is a CMP1.1 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> |
<<< Previous | Home | Next >>> |
Migrating JBoss specific descriptors | Up | Declaring EJB references |