| Author |
EJB relation one:many ??
|
Georg Joo
Ranch Hand
Joined: Feb 24, 2004
Posts: 49
|
|
Hi I have a prblem to understand the EJB relations. Example: the first table (invoice) has a key "Number" and the second table (invoicepositions) has the key "Number, Posnumber". The reltaion is 1:many unidirectional. How have I to solve this situation ? Has Bean invoice a CMR field "Number" ? This field this a CMP field (!?). Have I tho declare a CMR field "positions"? What's the right way to do this ? Thanks Georg
|
SCJP, SCWCD, SCBCD<br /> <br />Vienna, Austria
|
 |
Valentin Crettaz
Gold Digger
Sheriff
Joined: Aug 26, 2001
Posts: 7610
|
|
Actually, in the Invoice bean class, you should declare the following method that represents the invoicePositions CMR field: public abstract Collection getInvoicePositions(); The returned Collection will contain InvoicePositionLocal references. And now, your deployment descriptor should look like: Note that you can freely change the content of ejb-relation-name, ejb-relationship-role-name. I hope this helps
|
SCJP 5, SCJD, SCBCD, SCWCD, SCDJWS, IBM XML
[Blog] [Blogroll] [My Reviews] My Linked In
|
 |
Georg Joo
Ranch Hand
Joined: Feb 24, 2004
Posts: 49
|
|
Yes, this was the answer I need. Thanks Georg
|
 |
Valentin Crettaz
Gold Digger
Sheriff
Joined: Aug 26, 2001
Posts: 7610
|
|
And depending on your application server you still have to write the vendor-specific deployment descriptor for mapping the CMR fields to the proper columns in your database. Or you use XDoclet and you write everything in the source file  [ July 28, 2004: Message edited by: Valentin Crettaz ]
|
 |
Georg Joo
Ranch Hand
Joined: Feb 24, 2004
Posts: 49
|
|
Hi Can I map the CMR Field getInvoicePositions() to a PrimaryKey field ? I get always an error. Is it possible to use Number of the PK for the CMR field ??? (If it is possible, then I have to read the jonas documentation twice). Or have I to insert an own column for the CMR filed, that holds the same value as the Number of the PK (I thik not)??? Thanks Georg
|
 |
 |
|
|
subject: EJB relation one:many ??
|
|
|