File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

CMP maping - one to many unidirection in wl7.0

 
Sai Prasad
Ranch Hand
Posts: 560
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
sameerleekha
Greenhorn
Posts: 26
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic