Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Incorrect Cascade Discovery of new objects mapped from managed Embeddables
Incorrect Cascade Discovery of new objects mapped from managed Embeddables [message #1017751] Tue, 12 March 2013 13:32 Go to next message
J LM is currently offline J LMFriend
Messages: 11
Registered: December 2012
Junior Member
Hi,

Simple use case :
TcRoot (Entity) -> TcEmbeddable (Embeddable) -> TcSubEntity (Entity)

@Entity
@Table(name = "TCEMB_ROOT")
@SequenceGenerator(name = "SEQ_TCEMB_ROOT")
public class TcRoot implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE,
generator = "SEQ_TCEMB_ROOT")
@Column(name = "TCEMB_ROOT_ID")
private int id;

@Embedded
TcEmbeddable emb;

public void changeSub(final String newAttr) {
emb.changeSub(newAttr);
}
}


@Embeddable
public class TcEmbeddable implements Serializable {
@OneToOne
@JoinColumn(name = "SUBE_ID", referencedColumnName = "TCEMB_SUBE_ID")
TcSubEntity tcSE;

public void changeSub(final String newAttr) {
tcSE = new TcSubEntity(newAttr);
}
}

@Entity
@Table(name = "TCEMB_SUBE")
@SequenceGenerator(name = "SEQ_TCEMB_SUBE", sequenceName = "SEQ_TCEMB_SUBE")
public class TcSubEntity implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE,
generator = "SEQ_TCEMB_SUBE")
@Column(name = "TCEMB_SUBE_ID")
private int id;
}


After a find of a TcRoot (so managed) and a call on its method changeSub, a new SubEntity is created, transaction fails with Constraint Violation as the Id of the TcSubEntity is not set or take the 0 value.

Having looked at the code, the AggregateObjectMapping seems incomplete on the methods cascadeDiscoverAndPersistUnregisteredNewObjects.
One is inherited from DatabaseMapping which returns always false, the second one doesn't seem to be called.

Bug and Proposed patch for 2.3.X and 2.4.X : https://bugs.eclipse.org/bugs/show_bug.cgi?id=402865

[Updated on: Tue, 12 March 2013 13:34]

Report message to a moderator

Re: Incorrect Cascade Discovery of new objects mapped from managed Embeddables [message #1017837 is a reply to message #1017751] Tue, 12 March 2013 16:12 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1389
Registered: July 2009
Senior Member
This might have been just an oversight in describing the test case, but the TcEmbeddable's OneToOne relationship doesn't have cascade persist set. Without this set, the test case should be expected to fail. Can you verify that you get the same behavior with @OneToOne(cascade=ALL)?

Best Regards,
Chris
Re: Incorrect Cascade Discovery of new objects mapped from managed Embeddables [message #1017881 is a reply to message #1017837] Tue, 12 March 2013 17:35 Go to previous message
J LM is currently offline J LMFriend
Messages: 11
Registered: December 2012
Junior Member
I confirm the same behavior with cascade=ALL.
I've cleaned up too much my code for the description Sad

Julien.
Previous Topic:Entity instance not rollbacked
Next Topic:JPA-RS: @OneToMany: invalid output when retrieving relationship link
Goto Forum:
  


Current Time: Fri Apr 19 12:29:46 GMT 2024

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

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

Back to the top