• 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

EJB relation one:many ??

 
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Author & Gold Digger
Posts: 7617
6
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, this was the answer I need.

Thanks

Georg
 
Valentin Crettaz
Author & Gold Digger
Posts: 7617
6
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Rototillers convert rich soil into dirt. Please note that this tiny ad is not a rototiller:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic