• 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
  • Liutauras Vilda
  • Paul Clapham
  • paul wheaton
Sheriffs:
  • Tim Cooke
  • Devaka Cooray
  • Rob Spoor
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:

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.
 
What are your superhero powers? Go ahead and try them on this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic