How can an entity bean connect to two database tables using CMP(URGENT)
I need to connect my entity bean to 2 separate tables; On Create of the entity bean I should be able to insert record into 2 tables ,where each table has different fields?
Another thing i have been able to do this using BMP but how to do it with CMP ?
Please tell me how will i map two or more than two tables in the deployment descriptor , i am working on Weblogic Server
Dear u did not give much detial of your problem
1:: are you using EJB1.1 or EJB2.0
2:: you also not mentioned the relation between these two tables. if they have foreign key relation.
if u r using 1.1 then u can not do that in case of CMP. but u can do that by using sessionbean(what is the most appropriate for this type of problem). Make two seperate CMPs for every table. pass your data to the session bean which create them one by one.
if there is foregin key relation then u can do that in EJB2 by defining CMR fields.
further assistance will be provided when you give detailed description of your problem
Nayyer
thanks for your reply
1: i am using EJB 2.0 what i intended to ask was about the relationship of an entiy Bean with a dependent object class ,if a bean has many dependent objects then the Bean's Schema will span many tables in a Rdbms (oracle) how will i map to all these tables. i mean what entries will i have to make in the ejb-jar.xml and weblogic-rdbms-jar.xml
for examples i have a Customer bean having some simple fields like name ,age etc and two dependent objects like Habits and Hobbies
these are classes and also tables in the rdbms having many columns
My questions is how will i map all of them .
hope i have been explicit enough
There are third party tools for object-relational mapping that are designed to
do what you want. Take a look at CocoBase (http://www.thoughtinc.com/)
or Toplink (http://www.webgain.com/products/toplink/).
I know Cocobase in particular has an API that takes an XML file that describes
which fields you want to map to which columns of multiple tables. They have
a GUI to select tables and columns from your database schema so you don't
have to create the XML by hand. Their code essentially works with BMP but
it's just a couple of lines of code to call their API, which does all the work.
bgw2 at 2007-6-29 10:26:01 >
