• 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
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

CMR entity beans and primary key.

 
Ranch Hand
Posts: 165
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a question on select primary key. I have a entity bean called Customer and another
called Order. They have their own primary key: customerId for Customer and orderId for Order. One
Customer may have many Orders. I'm using CMR, so they are jared together. When I specified
<primkey-field> with different cmp field (customerId for Customer and orderId for Order) in ejb-jar.xml
I got following error when I try to put data in DB:

"When a cmp-field and cmr-field are mapped to the same column, the
setXXX method for the cmp-filed may not be called."
If I use customerId for both entity bean's <primkey-field>, it works fine.
I do not understand.
I read some examples on CMR entity beans, and find all of them are using same
<primkey-field>. Why I can not use different primary keys? I'm using WLS6.1SP3.
Thanks.
 
Ranch Hand
Posts: 560
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In your example, I guess, you must be having the Customer Id as the foreign key in the Order table. Right? May be try setting the combination of Customer Id and Order Id as keys.
 
John King
Ranch Hand
Posts: 165
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Sai.
If I also have LineIterm CMR entity beans.
Each Order can have many LineIterms. LineIterm
has a lineItermID as primary key and orderID
as foreign key. Should I create a composite
primary key that contains all there IDs (customerID,
orderID, and lineItermID) for all the CMR beans
(Customer, Order, LineIterm)? My basic question
is whether I can use different primary key for different CMR entity bean.
[ December 27, 2002: Message edited by: John King ]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic