• 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Liutauras Vilda
Sheriffs:
  • Paul Clapham
  • Jeanne Boyarsky
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
Bartenders:
  • Jesse Duncan
  • Frits Walraven
  • Mikalai Zaikin

Hibernate/JPA : EmbeddedId helpers

 
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've got a class with a composite primary key (I know, I know) ... in attempting to migrate away from hibernate xml I've had to implement a Primary key class and then add the appropriate

I've also added "helper" transient functions to allow existing code to use the fields of the primary key :


however when running dao tests I'm getting an error claiming that the Field is not present within the model class : ( org.hibernate.QueryException: could not resolve property ).

I'm able to get it to work by removing @Transient and adding @Column( name="...", insertable=false, updateable=false ) which to me seems counter-intuitive and probably not the preferred way.
 
Craig Taylor
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just as a followup as to how I figured it out:

I ended up using @IdClass to define the id class and then marked the individual getters with @Id as appropriate.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic