In EJB 2.0, What is a cmr-field. How can I differentiate between a cmr-field and a cmp-field?

prajakt samant

CMR stands for Container Managed Relation Field.

In EJB 2.0 Persistence of CMP bean is managed by a Persistence manager
The developer has to write his bean implementation class as abstract and Persistence Manager generates a concrete class for the bean.

I will try to give an Example:-
Bean Developers Class:-
public abstract EmployeeBean implements
javax.ejb.EntityBean {

public abstract void setFirstName(String firstName);
public abstract String getFirstName();
public abstract void setAddress(Address addr);
public abstract Address getAddres();

}//end of class

where Address is another abstract class(dependant object) having streetno,zip and other details

In Deployment Descriptor:-

<cmp-field><field-name>firstName</field-name></cmp-field>

<cmr-field>
<cmr-field-name>myaddress</cmr-field-name>
<cmr-field-type>Address</cmr-field-type>
</cmr-field>

Thus when Persistence manager generates the concrete class for above abstract class.It creates a variable "firstName" of type String as CMP and "myaddress" which of type Address, which is a CMR or also called as dependant object.
Regards
Prajakt

0 Comments  (click to add your comment)
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact