• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibernate/JPA : EmbeddedId helpers

 
Craig Taylor
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • 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
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic