Nary
2004-05-19 00:32:10 UTC
I have two CMPs, Customer and ContactInfo, with ContactInfo having a FK relationship
with Customer. (ContactInfo table contains CustomerID).
Scenario 1: ejbPostCreate() of Customer entity bean has the code to create the
child object ContactInfo Scenario 2: Customer and ContactInfo are created explicitly
from the session bean.
In both scenarios, I'm getting the following exception: javax.ejb.EJBException:
nested exception is: java.sql.SQLException: ORA-02291: integrity constraint (CONTACTINFO_CUSTOMER_FK)
violated - parent key not found
It worked fine when I was using persistence type as 5.1.0. Getting this exception
once I moved to CMP2.x
Using CMP2.x but not CMR. Using default values in the deployment descriptors.
Using local interfaces for entity beans.
It's looks as if the container is waiting for the end of transaction before inserting
the customer in the DB but doing it in the wrong order. i.e., sending the insert
for contact info before the customer insert.
Any help is appreciated. Thanks in advance. Scenario 1 sample code and the exception
stack trace attached at bottom.
A session bean to create the customer has: #######################################
public CustomerVO createCustomer(CustomerVO customerVO) {
CustomerHome custHome = ... jndi lookup... Customer customerLocal = custHome.create(customerVO);
CustomerVO createdCustomer = customerLocal.getCustomer(); return createdCustomer;
} #######################################
Customer entity bean has: ####################################### public String
ejbCreate(CustomerVO customerVO) throws CreateException { // create a primary
key and set it setId(createUniqueKey()); // set the attributes of the Customer
here..... }
public void ejbPostCreate(CustomerVO customerVO) throws CreateException { ContactInfoHome
contactHome = ...jndi lookup... String customerId = (String) getEntityContext().getPrimaryKey();
contactHome.create(customerId, customerVO.getContactInfo()); } #######################################
ContactInfo entity bean has: ####################################### public String
ejbCreate(String customerId, ContactInfoVO contactInfoVO) throws CreateException
{ // create a primary key and set it setId(createUniqueKey()); setCustomerId(customerId);
//set the attributes of the ContactInfo here..... }
public void ejbPostCreate(String customerId, ContactInfoVO contactInfoVO) throws
CreateException { // empty method } #######################################
Exception stack trace: javax.ejb.EJBException: nested exception is: java.sql.SQLException:
ORA-02291: integrity constraint (CONTACTINFO_CUSTOMER_FK) violated - parent key
not found at oracle.jdbc.dbaccess.DBError.throwSqlException(Ljava.lang.String;Ljava.lang.String;I)V(DBError.java:170)
at oracle.jdbc.ttc7.TTIoer.processError()V(TTIoer.java:218) at oracle.jdbc.ttc7.Oall7.receive()V(Oall7.java:543)
at oracle.jdbc.ttc7.TTC7Protocol.doOall7(BBI[B[Loracle.jdbc.dbaccess.DBType;[Loracle.jdbc.dbaccess.DBData;I[Loracle.jdbc.dbaccess.DBType;[Loracle.jdbc.dbaccess.DBData;I)V(TTC7Protocol.java:1427)
at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteFetch(Loracle.jdbc.dbaccess.DBStatement;B[BLoracle.jdbc.dbaccess.DBDataSet;ILoracle.jdbc.dbaccess.DBDataSet;I)I(TTC7Protocol.java:844)
at oracle.jdbc.driver.OracleStatement.executeNonQuery(Z)V(OracleStatement.java:1722)
at oracle.jdbc.driver.OracleStatement.doExecuteOther(Z)V(OracleStatement.java:1647)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout()V(OracleStatement.java:2167)
at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate()I(OraclePreparedStatement.java:404)
at weblogic.jdbc.wrapper.PreparedStatement.executeUpdate()I(PreparedStatement.java:95)
at weblogic.ejb20.manager.BaseEntityManager.executeInsertStmt(Ljava.util.List;Ljavax.transaction.Transaction;Ljava.util.Set;Z)V(BaseEntityManager.java:546)
at weblogic.ejb20.manager.BaseEntityManager.executeDBOperations(Ljava.util.List;Ljavax.transaction.Transaction;Ljava.util.Set;ZI)V(BaseEntityManager.java:435)
at weblogic.ejb20.internal.TxManager$TxListener.executeDBOperations(Ljava.util.Set;ZI)V(TxManager.java:596)
at weblogic.ejb20.internal.TxManager$TxListener.executeDBOperationsDriver(Z)V(TxManager.java:571)
at weblogic.ejb20.internal.TxManager$TxListener.flushModifiedKeys()V(TxManager.java:768)
at weblogic.ejb20.internal.TxManager.flushModifiedBeans(Ljavax.transaction.Transaction;)V(TxManager.java:350)
at weblogic.ejb20.manager.BaseEntityManager.flushModifiedBeans(Ljavax.transaction.Transaction;)V(BaseEntityManager.java:2301)
at weblogic.ejb20.cmp.rdbms.RDBMSPersistenceManager.flushModifiedBeans()V(RDBMSPersistenceManager.java:2672)
at ContactInfoHome_shdy1d__WebLogic_CMP_RDBMS.ejbFindByCustomer(Ljava.lang.String;)Ljava.util.Collection;(ContactInfoHome_shdy1d__WebLogic_CMP_RDBMS.java:528)
at COM.jrockit.reflect.NativeMethodInvoker.invoke0(ILjava.lang.Object;[Ljava.lang.Object;)Ljava.lang.Object;(Native
Method) at COM.jrockit.reflect.NativeMethodInvoker.invoke(Ljava.lang.Object;[Ljava.lang.Object;)Ljava.lang.Object;(Unknown
Source) at COM.jrockit.reflect.VirtualNativeMethodInvoker.invoke(Ljava.lang.Object;[Ljava.lang.Object;)Ljava.lang.Object;(Unknown
Source) at java.lang.reflect.Method.invoke(Ljava.lang.Object;[Ljava.lang.Object;I)Ljava.lang.Object;(Unknown
Source) at weblogic.ejb20.cmp.rdbms.RDBMSPersistenceManager.collectionFinder(Ljavax.ejb.EntityBean;Ljava.lang.reflect.Method;[Ljava.lang.Object;)Ljava.util.Collection;(RDBMSPersistenceManager.java:342)
at weblogic.ejb20.manager.BaseEntityManager.collectionFinder(Ljavax.transaction.Transaction;Ljava.lang.reflect.Method;[Ljava.lang.Object;ZZ)Ljava.util.Collection;(BaseEntityManager.java:1655)
at weblogic.ejb20.manager.BaseEntityManager.collectionFinder(Lweblogic.ejb20.interfaces.InvocationWrapper;Ljava.lang.reflect.Method;[Ljava.lang.Object;)Ljava.util.Collection;(BaseEntityManager.java:1627)
at weblogic.ejb20.internal.EntityEJBLocalHome.finder(Lweblogic.ejb20.internal.MethodDescriptor;[Ljava.lang.Object;I)Ljava.lang.Object;(EntityEJBLocalHome.java:467)
at ContactInfoHome_shdy1d_LocalHomeImpl.findByCustomer(Ljava.lang.String;)Ljava.util.Collection;(ContactInfoInfoHome_shdy1d_LocalHomeImpl.java:124)
at CustomerSessionBeanHome_fq6t6h_ELOImpl.getCustomer()
with Customer. (ContactInfo table contains CustomerID).
Scenario 1: ejbPostCreate() of Customer entity bean has the code to create the
child object ContactInfo Scenario 2: Customer and ContactInfo are created explicitly
from the session bean.
In both scenarios, I'm getting the following exception: javax.ejb.EJBException:
nested exception is: java.sql.SQLException: ORA-02291: integrity constraint (CONTACTINFO_CUSTOMER_FK)
violated - parent key not found
It worked fine when I was using persistence type as 5.1.0. Getting this exception
once I moved to CMP2.x
Using CMP2.x but not CMR. Using default values in the deployment descriptors.
Using local interfaces for entity beans.
It's looks as if the container is waiting for the end of transaction before inserting
the customer in the DB but doing it in the wrong order. i.e., sending the insert
for contact info before the customer insert.
Any help is appreciated. Thanks in advance. Scenario 1 sample code and the exception
stack trace attached at bottom.
A session bean to create the customer has: #######################################
public CustomerVO createCustomer(CustomerVO customerVO) {
CustomerHome custHome = ... jndi lookup... Customer customerLocal = custHome.create(customerVO);
CustomerVO createdCustomer = customerLocal.getCustomer(); return createdCustomer;
} #######################################
Customer entity bean has: ####################################### public String
ejbCreate(CustomerVO customerVO) throws CreateException { // create a primary
key and set it setId(createUniqueKey()); // set the attributes of the Customer
here..... }
public void ejbPostCreate(CustomerVO customerVO) throws CreateException { ContactInfoHome
contactHome = ...jndi lookup... String customerId = (String) getEntityContext().getPrimaryKey();
contactHome.create(customerId, customerVO.getContactInfo()); } #######################################
ContactInfo entity bean has: ####################################### public String
ejbCreate(String customerId, ContactInfoVO contactInfoVO) throws CreateException
{ // create a primary key and set it setId(createUniqueKey()); setCustomerId(customerId);
//set the attributes of the ContactInfo here..... }
public void ejbPostCreate(String customerId, ContactInfoVO contactInfoVO) throws
CreateException { // empty method } #######################################
Exception stack trace: javax.ejb.EJBException: nested exception is: java.sql.SQLException:
ORA-02291: integrity constraint (CONTACTINFO_CUSTOMER_FK) violated - parent key
not found at oracle.jdbc.dbaccess.DBError.throwSqlException(Ljava.lang.String;Ljava.lang.String;I)V(DBError.java:170)
at oracle.jdbc.ttc7.TTIoer.processError()V(TTIoer.java:218) at oracle.jdbc.ttc7.Oall7.receive()V(Oall7.java:543)
at oracle.jdbc.ttc7.TTC7Protocol.doOall7(BBI[B[Loracle.jdbc.dbaccess.DBType;[Loracle.jdbc.dbaccess.DBData;I[Loracle.jdbc.dbaccess.DBType;[Loracle.jdbc.dbaccess.DBData;I)V(TTC7Protocol.java:1427)
at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteFetch(Loracle.jdbc.dbaccess.DBStatement;B[BLoracle.jdbc.dbaccess.DBDataSet;ILoracle.jdbc.dbaccess.DBDataSet;I)I(TTC7Protocol.java:844)
at oracle.jdbc.driver.OracleStatement.executeNonQuery(Z)V(OracleStatement.java:1722)
at oracle.jdbc.driver.OracleStatement.doExecuteOther(Z)V(OracleStatement.java:1647)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout()V(OracleStatement.java:2167)
at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate()I(OraclePreparedStatement.java:404)
at weblogic.jdbc.wrapper.PreparedStatement.executeUpdate()I(PreparedStatement.java:95)
at weblogic.ejb20.manager.BaseEntityManager.executeInsertStmt(Ljava.util.List;Ljavax.transaction.Transaction;Ljava.util.Set;Z)V(BaseEntityManager.java:546)
at weblogic.ejb20.manager.BaseEntityManager.executeDBOperations(Ljava.util.List;Ljavax.transaction.Transaction;Ljava.util.Set;ZI)V(BaseEntityManager.java:435)
at weblogic.ejb20.internal.TxManager$TxListener.executeDBOperations(Ljava.util.Set;ZI)V(TxManager.java:596)
at weblogic.ejb20.internal.TxManager$TxListener.executeDBOperationsDriver(Z)V(TxManager.java:571)
at weblogic.ejb20.internal.TxManager$TxListener.flushModifiedKeys()V(TxManager.java:768)
at weblogic.ejb20.internal.TxManager.flushModifiedBeans(Ljavax.transaction.Transaction;)V(TxManager.java:350)
at weblogic.ejb20.manager.BaseEntityManager.flushModifiedBeans(Ljavax.transaction.Transaction;)V(BaseEntityManager.java:2301)
at weblogic.ejb20.cmp.rdbms.RDBMSPersistenceManager.flushModifiedBeans()V(RDBMSPersistenceManager.java:2672)
at ContactInfoHome_shdy1d__WebLogic_CMP_RDBMS.ejbFindByCustomer(Ljava.lang.String;)Ljava.util.Collection;(ContactInfoHome_shdy1d__WebLogic_CMP_RDBMS.java:528)
at COM.jrockit.reflect.NativeMethodInvoker.invoke0(ILjava.lang.Object;[Ljava.lang.Object;)Ljava.lang.Object;(Native
Method) at COM.jrockit.reflect.NativeMethodInvoker.invoke(Ljava.lang.Object;[Ljava.lang.Object;)Ljava.lang.Object;(Unknown
Source) at COM.jrockit.reflect.VirtualNativeMethodInvoker.invoke(Ljava.lang.Object;[Ljava.lang.Object;)Ljava.lang.Object;(Unknown
Source) at java.lang.reflect.Method.invoke(Ljava.lang.Object;[Ljava.lang.Object;I)Ljava.lang.Object;(Unknown
Source) at weblogic.ejb20.cmp.rdbms.RDBMSPersistenceManager.collectionFinder(Ljavax.ejb.EntityBean;Ljava.lang.reflect.Method;[Ljava.lang.Object;)Ljava.util.Collection;(RDBMSPersistenceManager.java:342)
at weblogic.ejb20.manager.BaseEntityManager.collectionFinder(Ljavax.transaction.Transaction;Ljava.lang.reflect.Method;[Ljava.lang.Object;ZZ)Ljava.util.Collection;(BaseEntityManager.java:1655)
at weblogic.ejb20.manager.BaseEntityManager.collectionFinder(Lweblogic.ejb20.interfaces.InvocationWrapper;Ljava.lang.reflect.Method;[Ljava.lang.Object;)Ljava.util.Collection;(BaseEntityManager.java:1627)
at weblogic.ejb20.internal.EntityEJBLocalHome.finder(Lweblogic.ejb20.internal.MethodDescriptor;[Ljava.lang.Object;I)Ljava.lang.Object;(EntityEJBLocalHome.java:467)
at ContactInfoHome_shdy1d_LocalHomeImpl.findByCustomer(Ljava.lang.String;)Ljava.util.Collection;(ContactInfoInfoHome_shdy1d_LocalHomeImpl.java:124)
at CustomerSessionBeanHome_fq6t6h_ELOImpl.getCustomer()