I have a table named GL_CHART_OF_ACCOUNT having a
compound primary key(account_ref_id,company_code).
The above PK is also a foreign key in the same table
(self relationship).
The relationship is one to many.
I have made an entity bean representing the above table.
I have an abstract method
"setGL_CHART_OF_ACCOUNT(GL_CHART_OF_ACCOUNT cAccount)"
for updating a relation.
GL_CHART_OF_ACCOUNT is an EjbObject.
Now I am updating a row
First I call cAccounts=ejbFindByPrimaryKey(new com.gl.beans.GL_CHART_OF_ACCOUNT_PK(account_ref_id,company_code)).
It returns the remote interface.
when I update a row and call setGL_CHART_OF_ACCOUNT(cAccount)
it throws
Remote Exception EJB Exception: ; nested exception is:
weblogic.transaction.RollbackException: Unexpected exception in beforeCompletion: sync = [email protected]
Error writing from beforeCompletion - with nested exception:
[weblogic.utils.NestedRuntimeException: Error writing from beforeCompletion - with nested exception:
[java.rmi.NoSuchObjectException: Exception from ejbStore:javax.ejb.NoSuchEntityException: Bean with primary key: [email protected] not found.]]
How do i fix it please give me the response........?
During entity creation it is working fine
I am using weblogic6.0Sp2 with EJB2.0
foreign keys are avaliable for all the values(account_ref_id,company_code).
actualy the row which it says not found is the parent row which i am trying to update and it 100% exists.
The adminstation tool of weblogic server also shows that the row is present in the cache.
my code is
************************************************************
public void updateChartOfAccounts(Integer accountRefId,String companyCode,String accountCode,String accountDesc,String accountNo,String basis,String accountLevel,String accountNature,String timeStamp,String parentCompanyCode,String parentAccountCode) throws RemoteException,FinderException,AccountCodeNotExistsException,CompanyNotExistsException,RecordHasBeenUpdatedException,ParentAccountCodeNotExistsException,NoSuchObjectException
{
GL_CHART_OF_ACCOUNT glChartOfAccount = null; lookupCompanyHome();
lookupChartOfAccountHome();
try
{
//Find Remote Interface of the Parent ChartOfAccount Row
if (parentCompanyCode.equals("") == false)
{
try
{
glParentChartOfAccount = glChartOfAccountHome.findByCompany_CodeAndAccount_Code(parentCompanyCode,parentAccountCode);
}
catch(javax.ejb.FinderException ex)
{
log("GL_CHART_OF_ACCOUNT_SESSION_EJB.updateChartOfAccounts() ParentAccountCodeNotExists Exception........................... ");
throw new ParentAccountCodeNotExistsException ("Record1:Parent Account Code "+parentAccountCode+" Not Exists for Company "+parentCompanyCode);
}
}
else
{
glParentChartOfAccount = null;
}
//Find Remote Interface of the Current ChartOfAccount Row
try
{
glChartOfAccount = glChartOfAccountHome.findByCompany_CodeAndAccount_Code(companyCode,accountCode);
}
catch(javax.ejb.FinderException ex)
{
throw new AccountCodeNotExistsException ("Record1:Account Code Not Exists for Company "+companyCode);
}
Find Remote Interface of the Company Row
try
{
glCompany= glCompanyHome.findByPrimaryKey(companyCode);
}
catch(javax.ejb.FinderException ex)
{
throw new CompanyNotExistsException ("Record1:Company Not Exists");
}
glChartOfAccount.setAccount_Code(accountCode);
glChartOfAccount.setAccount_Desc(accountDesc);
glChartOfAccount.setAccount_No(accountNo);
glChartOfAccount.setBasis(basis);
glChartOfAccount.setAccount_Level(accountLevel);
glChartOfAccount.setAccount_Nature(accountNature);
glChartOfAccount.setGL_CHART_OF_ACCOUNT(glParentChartOfAccount);
glChartOfAccount.setTimeStamp(new java.sql.Timestamp(new java.util.Date().getTime()));
}
catch(java.rmi.RemoteException ex)
{
log("GL_CHART_OF_ACCOUNT_SESSION_EJB.updateChartOfAccounts() RemoteException........................... ");
log(ex.getMessage());
}
catch(Exception ex)
{
log("GL_CHART_OF_ACCOUNT_SESSION_EJB.updateChartOfAccounts() Exception........................... ");
log(ex.getMessage());
}
}
**********************************************************
glChartOfAccount.setGL_CHART_OF_ACCOUNT(glParentChartOfAccount);
the above method is throwing the exception
<Jun 22, 2000 1:34:34 AM GMT+05:00> <Error> <EJB> <Exception during commit of transaction transaction=(IdHash=3428656,Name = [EJB GL_CHART_OF_ACCOUNT_SESSION_EJBImpl.updateChartOfAccounts()],Xid=289:b37b632e804b4999,Status=Rolled back. [Reason = weblogic.utils.NestedRuntimeException: Error writing from beforeCompletion - with nested exception:
[java.rmi.NoSuchObjectException: Exception from ejbStore:javax.ejb.NoSuchEntityException: Bean with primary key: '[email protected]' not found.]],numRepliesOwedMe=0,numRepliesOwedOthers=0,seconds since begin=0,seconds left=30,SCInfo[myserver]=(state=rolledback),properties=({weblogic.transaction.name=[EJB GL_CHART_OF_ACCOUNT_SESSION_EJBImpl.updateChartOfAccounts()]})): java.rmi.NoSuchObjectException: Exception from ejbStore:javax.ejb.NoSuchEntityException: Bean with primary key: '[email protected]' not found.
at weblogic.ejb20.internal.EJBRuntimeUtils.throwRemoteException(EJBRuntimeUtils.java:57)
at weblogic.ejb20.manager.DBManager.beforeCompletion(DBManager.java:364)
at weblogic.ejb20.internal.TxManager$TxListener.beforeCompletion(TxManager.java:211)
at weblogic.transaction.internal.ServerSCInfo.callBeforeCompletions(ServerSCInfo.java:511)
at weblogic.transaction.internal.ServerSCInfo.startPrePrepareAndChain(ServerSCInfo.java:78)
at weblogic.transaction.internal.ServerTransactionImpl.localPrePrepareAndChain(ServerTransactionImpl.java:893)
at weblogic.transaction.internal.ServerTransactionImpl.globalPrePrepare(ServerTransactionImpl.java:1229)
at weblogic.transaction.internal.ServerTransactionImpl.commit(ServerTransactionImpl.java:168)
at weblogic.ejb20.internal.BaseEJBObject.postInvoke(BaseEJBObject.java:201)
at com.gl.beans.GL_CHART_OF_ACCOUNT_SESSION_EJBEOImpl.updateChartOfAccounts(GL_CHART_OF_ACCOUNT_SESSION_EJBEOImpl.java:80)
at client.gl.beans.ChartOfAccountBean.editChartOfAccount(ChartOfAccountBean.java:107)
at client.gl.beans.ChartOfAccountBean.processRequest(ChartOfAccountBean.java:64)
at jsp_servlet._chartofaccountscontroller._jspService(_chartofaccountscontroller.java:240)
at weblogic.servlet.jsp.JspBase.service(JspBase.java:27)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:213)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:246)
at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:1265)
at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:1631)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:137)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
-
updating a composite relation(foreign key) (2 messages)
- Posted by: burhan ahmed
- Posted on: September 07 2001 06:16 EDT
Threaded Messages (2)
- updating a composite relation(foreign key) by Gal Binyamini on September 07 2001 17:05 EDT
- updating a composite relation(foreign key) by burhan ahmed on September 08 2001 12:42 EDT
-
updating a composite relation(foreign key)[ Go to top ]
- Posted by: Gal Binyamini
- Posted on: September 07 2001 17:05 EDT
- in response to burhan ahmed
Just a shot in the dark: are you sure you implemented the equals() and hashCode() methods correctly in your PK? -
updating a composite relation(foreign key)[ Go to top ]
- Posted by: burhan ahmed
- Posted on: September 08 2001 12:42 EDT
- in response to Gal Binyamini
My PK class is as follow
package com.gl.beans;
import java.io.Serializable;
final public class GL_CHART_OF_ACCOUNT_PK implements Serializable
{
private transient int m_hashCode = -1;
public java.lang.Integer account_Ref_Id;
public java.lang.String company_Code;
public GL_CHART_OF_ACCOUNT_PK()
{
}
public GL_CHART_OF_ACCOUNT_PK(java.lang.Integer account_Ref_Id, java.lang.String company_Code)
{
this.account_Ref_Id = account_Ref_Id;
this.company_Code = company_Code;
}
public int hashCode()
{
if (-1 == m_hashCode)
{
m_hashCode = (account_Ref_Id.hashCode()) ^ (company_Code.hashCode());
}
return m_hashCode;
}
public boolean equals(Object other)
{
if (other == this)
{
return true;
}
if (null == other)
{
return false;
}
if (other.hashCode() != hashCode())
{
return false;
}
try
{
com.gl.beans.GL_CHART_OF_ACCOUNT_PK other2 = (com.gl.beans.GL_CHART_OF_ACCOUNT_PK) other;
return (this.account_Ref_Id.equals(other2.account_Ref_Id)) && (this.company_Code.equals(other2.company_Code));
}
catch(ClassCastException ex)
{
return false;
}
}
public Integer getAccount_Ref_Id()
{
return account_Ref_Id;
}
public String getCompany_Code()
{
return company_Code;
}
}