JBoss.org Community Documentation
CMR-Field abstract accessors have the same signatures as cmp-fields
, except that single-valued relationships must return the local interface of the related entity, and multi-valued relationships can only return a java.util.Collection
(or java.util.Set
) object. For example, to declare a one-to-many relationship between organization and gangster, we declare the relationship from organization to gangster in the OrganizationBean
class:
public abstract class OrganizationBean implements EntityBean { public abstract Set getMemberGangsters(); public abstract void setMemberGangsters(Set gangsters); }
We also can declare the relationship from gangster to organization in the GangsterBean
class:
public abstract class GangsterBean implements EntityBean { public abstract Organization getOrganization(); public abstract void setOrganization(Organization org); }
Although each bean declared a CMR field, only one of the two beans in a relationship must have a set of accessors. As with CMP fields, a CMR field is required to have both a getter and a setter method.