This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes EJB and other Java EE Technologies and the fly likes EJB and CMR questions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "EJB and CMR questions" Watch "EJB and CMR questions" New topic

EJB and CMR questions

John Menarek

Joined: Mar 24, 2004
Posts: 1
I am new to EJB and have questions that pertain to two areas about CMR. The first area is conceptually how the EJBs and related entities are created. The second is about jbosscmp-jdbc.xml
Any help would be greatly appreciated
Reference for questions: BillingEJB has a ContactEJB, it�s a unidirectional one to one relationship
Note*** some of my assumptions maybe wrong to misconfiguration issues with JBoss
In regards to EJB creation and related entities

1.One can have a foreign key to another relation. But to what end? The BillingEJB can have the ContactEJB phone number pk. If I create a BillingEJB and use a �remote� ContactEJB I can only set the foreign key cmp. I cannot set the contact cmr field and the container does not use the foreign key to set it for me. At least when I tested creating an BillingEJB with a remote ContactEJB and trying to get the contacts name I got a null pointer exception because the cmr field was null. Is the foreign key only to aid in the use of �find� and �select� methods?
2.If my assertions are correct in the first question than it follows that the remote interface of an object with cmr relationships is essentially useless. I state this because the only way to set the CMR field is with a local interface in the postCreate method and you can only create a local interface in the container.
3.If my assertions are correct again than some higher level object, a session bean, a delegate, whatever will be required by the client to instantiate any entity beans with cmrs
In regards to jbosscmp-jdbc.xml and maybe this is why I am incurring some of my problems. My relationship from the BillingEJB to the ContactEJB looks like:
<!-- Note: Field in Billing. -->
<!-- Note: Column in Contact table. -->
As I understand it the reference EJB is Billing so why do I have specify its key? shouldn't it be something like

<!-- Note: Field in Billing. -->
<field-name>contactPhoneNumber</field-name> THE FOREIGN KEY
<!-- Note: Column in Contact table. -->
<column-name>phoneNumber</column-name> THE PK in ContactEJB
I agree. Here's the link:
subject: EJB and CMR questions
It's not a secret anymore!