Win a copy of Kubernetes in Action this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

EJB relation one:many ??  RSS feed

 
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Gold Digger
Sheriff
Posts: 7610
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Georg Joo
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, this was the answer I need.

Thanks

Georg
 
Valentin Crettaz
Gold Digger
Sheriff
Posts: 7610
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!