Hi,
we are facing following problem and are not able to solve it.
we have to entities in 1:N relationship mapped in following way:
Code:
@Entity
PartnerExport {
@OneToMany(targetEntity = MarkedExport.class, cascade=CascadeType.ALL, mappedBy = "export")
private Set<MarkedExport> marks = new HashSet<MarkedExport>(0);
....
}
@Entity
MarkedExport {
@ManyToOne(fetch=FetchType.LAZY)
@JoinColumn(name = "PARTNEREXPORT_ID", insertable = false, updatable = false)
private PartnerExport export;
...
}
and we add MarkedExport instance into collection 'marks' and also register PartnerExport to MarkedExport.
Code:
PartnerExport export = new PartnerExport();
MarkedExport mark = new MarkedExport();
export.getMarks().add(mark);
mark.setExport(export);
now we need to save 'export' entity (using merge or persist), but we are getting following exception:
javax.resource.spi.LocalTransactionException: ORA-02091: transaction rolled back
ORA-02291: integrity constraint (MARKEDEXPORT_PEXPORT_FK) violated - parent key not found
at com.sun.gjc.spi.LocalTransaction.commit(LocalTransaction.java:93)
at com.sun.enterprise.resource.ConnectorXAResource.commit(ConnectorXAResource.java:114)
at com.sun.enterprise.distributedtx.J2EETransaction.commit(J2EETransaction.java:471)
at com.sun.enterprise.distributedtx.J2EETransactionManagerOpt.commit(J2EETransactionManagerOpt.java:371)
at com.sun.ejb.containers.BaseContainer.completeNewTx(BaseContainer.java:3817)
at com.sun.ejb.containers.BaseContainer.postInvokeTx(BaseContainer.java:3596)
at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:1379)
at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:1316)
at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:205)we really don't know what is wrong with our dependent object (MarkedExport) and why hibernate cannot fill foreign key, when saving both object via cascade.
thanx for hint