Community
Participate
Working Groups
Created attachment 228177 [details] Patch on AggregateObjectMapping for cascadeDiscovery methods 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. Proposed patch in attachment, compatible with 2.3.X and 2.4.X
Created attachment 228985 [details] Patch on AggregateObjectMapping for cascadeDiscovery methods by cascading the objectReferenced.
The attached Patch resolves the issue.
Patch still needed.
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink