• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

EJB and CMR questions

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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>
 
Won't you please? Please won't you be my neighbor? - Fred Rogers. Tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic