Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Cannot add or update a child row when using @EmbeddedId

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I have the following objects:

User Object:


UserReason Object:


And UserReasonPK object:


I want to be able to add userReason to the list, and that Hibernate will automatically update the reference between the parent & child object.

When using the above code, when trying to start the server, i'm getting the error message:


Please notice that i mapped the userId in UserReasonPK with insertable = false, updatable = false.

If i change it, and add this on the User property in UserReason object, server is up, but when trying to insert new User i'm getting the following error:


 
Creator of Enthuware JWS+ V6
Posts: 3349
303
Android Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Daphna,

The problem is that you have the userId in both the EmbeddedId as in the relationship to the User Entity. If I remember it well you can use the @MapsId annotation to indicate that the userId is mapped to the User Entity:

Regards,
Frits
 
daphna deutsch
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Frits,
thanks for you help.
it did fix the problem!

Daphna
 
daphna deutsch
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

daphna deutsch wrote:Hello,

I have the following objects:

User Object:


UserReason Object:


And UserReasonPK object:


I want to be able to add userReason to the list, and that Hibernate will automatically update the reference between the parent & child object.

When using the above code, when trying to start the server, i'm getting the error message:


Please notice that i mapped the userId in UserReasonPK with insertable = false, updatable = false.

If i change it, and add this on the User property in UserReason object, server is up, but when trying to insert new User i'm getting the following error:


 
    Bookmark Topic Watch Topic
  • New Topic