aspose file tools
The moose likes Object Relational Mapping and the fly likes JPA reference OneToOne CascadeType problems Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Reply Bookmark "JPA reference OneToOne CascadeType problems " Watch "JPA reference OneToOne CascadeType problems " New topic
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!
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: JPA reference OneToOne CascadeType problems
 
Similar Threads
Bidirection join broken in one direction?
Composite key in collection of basic type
Automatically Persisting non existing entity in One To One mapping
a complex one-to-one problem
data model for any orm framework