• 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 3 OneToMany with Composite Key

 
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

Having a problem setting up my first EJB 3 OneToMany relationship with a composite key.

Here's the error:
14:09:01,812 WARN [JDBCExceptionReporter] SQL Error: 957, SQLState: 42000
14:09:01,812 ERROR [JDBCExceptionReporter] ORA-00957: duplicate column name

The 'One' Entity:

The 'Many' Entity:

The Composite Key:



As you can see, I'm trying to map the CommsMessage to multiple CommsRecipients using the 'messageid' value found in both tables.

Any help greatly appreciated.
[ July 04, 2007: Message edited by: Dean Pullen ]
 
author
Posts: 304
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Dean,

You need to make one of your messageId mappings read-only in the CommsMessageRecipient class. We talk about this problem in Chapter 8 of our book, but essentially depending upon the vendor you should make either the ManyToOne mapping to or the @Id mapping as insertable=false, updatable=false.

BTW, in future I think you are supposed to post JPA questions in the O/R forum. Thanks.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic