Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Nested cascade
Nested cascade [message #834951] Mon, 02 April 2012 15:45 Go to next message
Diego Silva is currently offline Diego SilvaFriend
Messages: 4
Registered: April 2012
Junior Member
Initially I'm using EclipseLink which is integrated into the WebLogic 10.35 libraries.
I have an entity X, it has a ManyToOne relationship to Y represented as follows:

@ ManyToOne (cascade = CascadeType.PERSIST)
@ JoinColumn (name = "yid", nullable = false)
private Y y;

the entity X also has a OneToOne relationship to herself.

@ OneToOne (cascade = CascadeType.PERSIST)
@ JoinColumn (name = "xid_herself", nullable = false)
private X x;

If I have an insert operation that are present are the following:

X x1;
X x2;

Y y;

x1.setY (y);
x2.setY (y);

x1.setX (x2);
x2.setX (x1);

y.add (x1);
y.add (x2);

entityManagerInstance.persist (y);

This insertion throws an exception because it can not insert the value of y in the x attribute of entities X, because it is null. Basically it features a loop. How do I solve this problem?


Com o cascade Persist a apido eclipselink deveria resolver este conflito ?

* Recalling that the values ​​of X and Y are merely representative.
Re: Nested cascade [message #841633 is a reply to message #834951] Wed, 11 April 2012 15:17 Go to previous messageGo to next message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

You have made a data model that it is impossible to insert into.

You need to remove the nullable=false from one of the sides (or both),

or, probably better make both relationships use the same foreign key.
To do this use a mappedBy in the OneToOne (the other side should also be a OneToOne).
But this depends if it is actually the same relationship.



James : Wiki : Book : Blog : Twitter
Re: Nested cascade [message #841834 is a reply to message #841633] Wed, 11 April 2012 19:27 Go to previous message
Diego Silva is currently offline Diego SilvaFriend
Messages: 4
Registered: April 2012
Junior Member
Yeah, problem solved. I had generated my ddl using hibernate and with nulable property seted with true, then the hibernate generated a constraint, but eclipse link don't suport referential integrity. For solve the problem only need remove that constraint.
Previous Topic:getOldValue not exists in Interface ChangeRecord
Next Topic:@Embedded with CascadeType.PERSIST + orphanRemoval = true
Goto Forum:
  


Current Time: Thu Apr 25 04:35:31 GMT 2024

Powered by FUDForum. Page generated in 0.03078 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top