Originally posted by Erik:
Hi,
I have been reading about CMR and there is one question I could not find an explicit answer to and this is how to support relations between CMP and BMP entity beans. As I can see it there are no restrictions here so any of the following is possible:
1. a uni-directional relation from a CMP to a BMP entity bean
2. a uni-directional relation from a BMP to a CMP entity bean
3. a bi-directional relation between a CMP and BMP entity bean
Of course, also in all variants: one-to-one, one-to-many, many-to-one, many-to-many.
Can anyone confirm this?
Cheers
Erik
Hi Erik,
I am not sure from where you have read that any type of relationship ( 1->1 or 1->many or Many->Many) between BMP and CMP is possible.
EJB specification clearly says that relationships between entity beans can be managed (Transparently) by the Container ONLY when the persistence is Container Managed. This would provide the visibility to the Container to understand how the tables of the entity beans involved in relationships, mapped at the database end , by which it can transparently manage the relationships.
You can certainly have one or more BMP entity beans as a instance variable of CMP bean and vice versa but you will not be able to get the transparent relationship management ( For ex: when a child entity bean is added/deleted - adding or deleting it at the database end) provided by the Container as Container will not have the visibility to the BMP bean and the table it is mapped to( Note that all the Persitence code has to be written inside the bean itself).
Please read the section "10.3.2 The Entity Bean Provider�s View of Persistent Relationships" for more details on the entity bean relationship.
Regards
Karim