File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Object Relational Mapping and the fly likes JPA reference OneToOne CascadeType problems 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 "JPA reference OneToOne CascadeType problems " Watch "JPA reference OneToOne CascadeType problems " New topic

JPA reference OneToOne CascadeType problems

Sergey Deplake

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: 553
You need to set both sides of the relationship.


TopLink : EclipseLink : Book:Java Persistence : Blog:Java Persistence Performance
Sergey Deplake

Joined: Apr 13, 2010
Posts: 13
Thank you for help. Now everything work correct!
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: JPA reference OneToOne CascadeType problems
Similar Threads
Composite key in collection of basic type
data model for any orm framework
a complex one-to-one problem
Bidirection join broken in one direction?
Automatically Persisting non existing entity in One To One mapping