• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

CMP maping - one to many unidirection in wl7.0

 
Ranch Hand
Posts: 560
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I like to do the following:
1) Map one bean corresponding to table A to many beans corresponding to table B
2) table B has two columns as the primary keys.
3) One of the primary key column in table B is a foreign key pointing to the primary key of table A.
I am not able to map this scenario. I guess the mapping is possible as long as each table has its own unrelated primary keys. If anyone has tried this, please...please...help.
Thanks.
 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
You can use the following code for providing the mapping of Bean corresponding to table A with Beans corresponding to table B
<relationships>
<ejb-relation>
<ejb-relation-name>BeanA_with_BeanB1</ejb-relation-name>
<ejb-relationship-role>
<ejb-relationship-role-name>XXXXXXXXXXXXX</ejb-relationship-role-name>
<multiplicity>one</multiplicity>
<relationship-role-source>
<ejb-name>BEANA</ejb-name>
</relationship-role-source>
</ejb-relationship-role>
<ejb-relationship-role>
<ejb-relationship-role-name>YYYYYYYYYYYY</ejb-relationship-role-name>
<multiplicity>many</multiplicity>
<relationship-role-source>
<ejb-name>BeanB1</ejb-name>
</relationship-role-source>
</ejb-relationship-role>
</ejb-relation>
<ejb-relation>
<ejb-relation-name>BeanA_with_BeanB2</ejb-relation-name>
<ejb-relationship-role>
<ejb-relationship-role-name>XXXXXXXXXXXXX</ejb-relationship-role-name>
<multiplicity>one</multiplicity>
<relationship-role-source>
<ejb-name>BEANA</ejb-name>
</relationship-role-source>
</ejb-relationship-role>
<ejb-relationship-role>
<ejb-relationship-role-name>YYYYYYYYYYYY</ejb-relationship-role-name>
<multiplicity>many</multiplicity>
<relationship-role-source>
<ejb-name>BeanB2</ejb-name>
</relationship-role-source>
</ejb-relationship-role>
</ejb-relation>
</relationships>
 
Sai Prasad
Ranch Hand
Posts: 560
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am not sure why you would need to define two <ejb-relation> elements. For examples, I have one Customer bean related to many Address beans. In ejb-jar.xml, I have defined <ejb-relation> element as follows:

Now I like to know how you define the above relationship in weblogic-cmp-rdbms-jar.xml. The table for CustomerBean is CUSTOMER with CUSTOMER_ID as the primary key. The table for AddressBean is ADDRESS with CUSTOMER_ID and ADDRESS_TYPE as compound primary keys.
I hope I explained my problem clearly. Please help. Thanks.
 
sameerleekha
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,
I think u are thinking the simple prob. in a complex way.
Just define the maping for both the beans with their corresponding tables in a simple way as the mapping between the database field and the bean field.
Just inclue the foreigh key also like the other column feilds with the mapping between the foreign field name and the columm field name.
hope the above will help...
 
Sai Prasad
Ranch Hand
Posts: 560
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sameer,
I hope it is that simple. May be I didn't understand your sample ejb-jar.xml. I can map the Customer bean to customer table and Address bean to Address table. That is not the issue here. I like to use CMR to take advantage of,
1) cascade delete
2) automatic update of Address table by adding and removing the Collection objects in Customer bean.
Thanks again.
 
Can you smell this for me? I think this tiny ad smells like blueberry pie!
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic