Win a copy of Head First Android this week in the Android forum!

John Menarek

Greenhorn
+ Follow
since Mar 24, 2004
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by John Menarek

Hi,
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:
<ejb-relationship-role>
<ejb-relationship-role-name>
Billing-Has-Contact
</ejb-relationship-role-name>
<key-fields>
<key-field>
<!-- Note: Field in Billing. -->
<field-name>billingId</field-name>
<!-- Note: Column in Contact table. -->
<column-name>phoneNumber</column-name>
</key-field>
</key-fields>
</ejb-relationship-role>
As I understand it the reference EJB is Billing so why do I have specify its key? shouldn't it be something like

<key-fields>
<key-field>
<!-- 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
</key-field>
</key-fields>