This week's book giveaways are in the AI and JavaScript forums.
We're giving away four copies each of GANs in Action and WebAssembly in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of GANs in ActionE this week in the AI forum
or WebAssembly in Action 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
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
Sheriffs:
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Joe Ess
  • salvin francis
  • fred rosenberger

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: 3315
298
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:


 
Tick check! Okay, I guess that was just an itch. Oh wait! Just a tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!