Skip to Main Content

Integration

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

persist problem in cascade using @OneToMany

user559087Sep 24 2009 — edited Jun 7 2010
We are trying to persist an object which has a OneToMany relationship to other objects with CascadeType.ALL

When we persist, the log shows that it creates the INSERT statement with the correct bind variables (sequence-generated REPORT_ID, etc.) for the first object.

The problem happens when it tries to cascade and insert the Many part. The log shows the it tries to create the INSERT statement for the second object but the bind variable for the REPORT_ID is null.
Since we defined the relationship of the OneToMany using the REPORT_ID, we assumed that the REPORT_ID that was auto-generated for the first object would be used for the @Many objects.

What are we missing ??????

First Object:

@Id
@SequenceGenerator(name = "REPORT_HEADER_S", initialValue = 1, allocationSize = 1)
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "REPORT_HEADER_S")
@Column(name = "REPORT_ID", nullable = false)
private Long reportId;

@OneToMany(mappedBy = "report", cascade = { CascadeType.ALL})
private List<Summary> summaryList;

Second Object

@ManyToOne
@JoinColumn(name = "REPORT_ID", referencedColumnName = "REPORT_ID")
private Report report;
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 5 2010
Added on Sep 24 2009
6 comments
4,818 views