| Author |
JPA reference OneToOne CascadeType problems
|
Sergey Deplake
Greenhorn
Joined: Apr 13, 2010
Posts: 13
|
|
There are 2 tables in database and 2 entities according them. I make them easier.
Table 1 and entity:
Table 2 and entity:
Then I make 2 objects. First of the first entity, second of the second entity. Then set second object into first and persist first entity. In result first table fill in correctly, but in the second table appiars a problem. Field Table1Id contains null, but not id of the first entity. Why is it so? What can be the problem of this and how can I solve my problem?
|
 |
James Sutherland
Ranch Hand
Joined: Oct 01, 2007
Posts: 550
|
|
You need to set both sides of the relationship.
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
|
 |
Sergey Deplake
Greenhorn
Joined: Apr 13, 2010
Posts: 13
|
|
Thank you for help. Now everything work correct!
|
 |
 |
|
|
subject: JPA reference OneToOne CascadeType problems
|
|
|