This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Object Relational Mapping and the fly likes Problem at insert with relationship JPA 2.0 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Problem at insert with relationship JPA 2.0" Watch "Problem at insert with relationship JPA 2.0" New topic
Author

Problem at insert with relationship JPA 2.0

Miltos Tereres
Ranch Hand

Joined: Sep 04, 2009
Posts: 32
Here is my Employee entity




Here is my Account Entity



When i try to add a new employee


in the database at the ACCOUNT table i get EMPLOY_ID NULL
why does this happen? what can i do ?
Thank you for your time...
James Sutherland
Ranch Hand

Joined: Oct 01, 2007
Posts: 553
You need to set the employee in the Account (you need a setEmployee() method in Account).

See,
http://en.wikibooks.org/wiki/Java_Persistence/Relationships#Object_corruption.2C_one_side_of_the_relationship_is_not_updated_after_updating_the_other_side


TopLink : EclipseLink : Book:Java Persistence : Blog:Java Persistence Performance
Miltos Tereres
Ranch Hand

Joined: Sep 04, 2009
Posts: 32
Thank you for the reply...
I am trying to understand why it works only from the owner side in one to one relationships...
I will read again your link...

so doing ac.setemploye() only instead of e.setaccount it would work?
i ll try...thanks...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem at insert with relationship JPA 2.0
 
Similar Threads
Is the statement about EJB 3.x right?
JPA + Glassfish + Netbeans+enity class + generate tables =(
JPA returning collection of type PersistentBag instead of ArrayList
Beans binding with local variable
hashCode() & equals() method test