This week's book giveaway is in the Functional programming forum.
We're giving away four copies of Functional Design and Architecture and have Alexander Granin on-line!
See this thread for details.
Win a copy of Functional Design and Architecture this week in the Functional programming forum!
  • 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 ...
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Choose primary key for CMR entity beans

Ranch Hand
Posts: 165
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi everyone,
I have a question on choose primary key for CMR entity beans. I'm using following entity beans:
Customer, Order, and LineIterm. They have their own primary key: customerId for Customer, orderId for Order,
and lineItermId for LineIterm. Customer has a orderId as its foreign key while Order has customerId
and lineItermId as its foreign keies. One Customer may have many Orders, and one Order may have many
LineIterms. I'm using CMR, so they are jared together. When I specified
<primkey-field> with different cmp field (customerId for Customer, orderId for Order, lineItermId for
LineIterm) 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 all entity beans' <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>. My question
is whether I can use different primary key for different CMR entity bean and why?
Thanks for any inputs.
    Bookmark Topic Watch Topic
  • New Topic