I have table Quote (parent) and table QuotePartner (child), relationship
1-to-1, managed as CMP using ejb 2.0 on a WebLogic Server.
The problem is that a need to maintain relation 1-to-1, it means when a
Quote is created, inmediately I create QuotePartner on method
ejbPostCreate(), but it seems that first create child on database before
insert parent, because a database integrity constrint is fired.
I disabled that contraint and it works, but I wondering a way to implement
this withou disable database constraint.
Any idea or coments will be gratefully received
Thanks in advance
QuoteBean.java code:
public java.math.BigDecimal ejbCreate() throws CreateException {
BigDecimal vQuotePK = ....// autogenerated ID managed by my own
code
this.setQuoteid( vQuotePK ); // set parent id
}
public void ejbPostCreate() throws CreateException {
System.out.println("QuoteBean.ejbPostCreate");
// create QuotePartner
QuotepartnerHome vPartnerHome = null;
try{
System.out.println("QuoteBean.ejbPostCreate creating Context");
javax.naming.Context context = new
javax.naming.InitialContext();
System.out.println("QuoteBean.ejbPostCreate look home");
vPartnerHome =(QuotepartnerHome)context.lookup("Quotepartner");;
}catch(javax.naming.NamingException e){
System.out.println("QuoteBean.ejbPostCreate Error :"+
e.getExplanation());
e.printStackTrace(System.out);
throw new javax.ejb.EJBException( e.getMessage() );
}
BigDecimal vQuotePK = this.getQuoteid(); // get parent Id
System.out.println("QuoteBean.ejbPostCreate creating QuotePartner");
Quotepartner vPartner = vPartnerHome.create(vQuotePK );
//create child
}
Error:
java.rmi.RemoteException: EJB Exception:; nested exception is:
javax.ejb.TransactionRolledbackLocalException: EJB Exception:
- with nested exception:
[java.sql.SQLException: ORA-02291: integrity constraint
(JMACAVILCA.SYS_C00306834) violated - parent key not found
]
Start server side stack trace:
java.rmi.RemoteException: EJB Exception:; nested exception is:
javax.ejb.TransactionRolledbackLocalException: EJB Exception:
- with nested exception:
[java.sql.SQLException: ORA-02291: integrity constraint
(JMACAVILCA.SYS_C00306834) violated - parent key not found
] java.sql.SQLException: ORA-02291: integrity constraint
(JMACAVILCA.SYS_C00306834) violated - parent key not found
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:168)
at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:208)
at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:543)
at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1405)
at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteFetch(TTC7Protocol.java:822)
at
oracle.jdbc.driver.OracleStatement.executeNonQuery(OracleStatement.java:1446
)
at
oracle.jdbc.driver.OracleStatement.doExecuteOther(OracleStatement.java:1371)
at
oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java
:1900)
at
oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedState
ment.java:363)
at weblogic.jdbc.pool.Statement.executeUpdate(Statement.java:293)
at
weblogic.jdbc.rmi.internal.PreparedStatementImpl.executeUpdate(PreparedState
mentImpl.java:64)
at
weblogic.jdbc.rmi.SerialPreparedStatement.executeUpdate(SerialPreparedStatem
ent.java:58)
at
com.transi.ejb.Quotepartner_rihass__WebLogic_CMP_RDBMS.__WL_create(Quotepart
ner_rihass__WebLogic_CMP_RDBMS.java:2981)
at
com.transi.ejb.Quotepartner_rihass__WebLogic_CMP_RDBMS.ejbPostCreate(Quotepa
rtner_rihass__WebLogic_CMP_RDBMS.java:2825)
at java.lang.reflect.Method.invoke(Native Method)
at weblogic.ejb20.manager.DBManager.create(DBManager.java:583)
at weblogic.ejb20.manager.DBManager.localCreate(DBManager.java:471)
at
weblogic.ejb20.internal.EntityEJBLocalHome.create(EntityEJBLocalHome.java:16
7)
at
com.transi.ejb.QuotepartnerBean_rihass_LocalHomeImpl.create(QuotepartnerBean
_rihass_LocalHomeImpl.java:118)
at com.transi.ejb.QuoteBean.ejbPostCreate(QuoteBean.java:64)
at
com.transi.ejb.Quote_1aoeos__WebLogic_CMP_RDBMS.ejbPostCreate(Quote_1aoeos__
WebLogic_CMP_RDBMS.java:3189)
at java.lang.reflect.Method.invoke(Native Method)
at weblogic.ejb20.manager.DBManager.create(DBManager.java:583)
at weblogic.ejb20.manager.DBManager.remoteCreate(DBManager.java:462)
at weblogic.ejb20.internal.EntityEJBHome.create(EntityEJBHome.java:190)
at
com.transi.ejb.QuoteBean_1aoeos_HomeImpl.create(QuoteBean_1aoeos_HomeImpl.ja
va:107)
at com.transi.ejb.QuoteBean_1aoeos_HomeImpl_WLSkel.invoke(Unknown Source)
at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:296)
at
weblogic.rmi.cluster.ReplicaAwareServerRef.invoke(ReplicaAwareServerRef.java
:93)
at
weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:265)
at
weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest.java:2
2)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:139)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".