ibm.com/developerWorks
Presented by developerWorks, your source for great tutorials
DeptBean
...
This is a cmp field.
id
Notice that with the ejb.persistent field you do not specify the name of the field. Thus if
you changed the names of the CMP field, that is,
getTheID
,
setTheID
, you would
not have to manually sync the deployment descriptor. This is the beauty of XDoclet; it
knows about the context of the declaration. These are the features that make
refactoring code easier.
XDoclet and EJB technology: Set the vendor specific
OR mapping with the vendor specific tag (or not)
The
ejb.persistence
tag allows you to specify the mapping from a cmp field to a
table column. Here is an example of using the
ejb.persistence
tag with the
DeptBean
 s ID CMP field as follows:
/**
* This is a cmp field. The cmp field is read only.
* And it is the primary key.
*
* @ejb.pk field
* @ejb.persistent field
* @ejb.interface method view type="local"
* @ejb.persistence
column name="DEPTID"
* @resin ejb.cmp field
sql column="DEPTID"
*/
public abstract Integer getId();
public abstract void setId(Integer id);
Notice that the above ejb.persistence maps the ID CMP field to the DEPTID column.
(In this example I also use the vendor specific mapping tag since not all vendor
templates support the new
ejb.persistence
tag yet). The above XDoclet tags
would generate the following mappings in the vendor specific RDBMS mapping files.
Resin s resin.ejb
Page 36 of 49
Enhance J2EE component reuse with XDoclets






footer




 

 

 

 

 Home | About Us | Network | Services | Support | FAQ | Control Panel | Order Online | Sitemap | Contact

j2ee web hosting

 

Our partners: PHP: Hypertext Preprocessor Best Web Hosting Java Web Hosting Jsp Web Hosting Cheapest Web Hosting

Visionwebhosting.net Business web hosting division of Web Design Plus. All rights reserved