• 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
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

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.
 
To get a wish, you need a genie. To get a genie, you need a lamp. To get a lamp, you need a tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic