Hi,
I made bean managed entity bean on weblogic.I am calling ejbFindByPrimaryKey method from
jsp client.My bean is invoking unsetEntityContext() before ejbFindByPrimaryKey()& after setEntityContext().Again it calls setEntityContext() & then ejbFindByPrimaryKey().In this method i am populating the instance with desired data.But when I am calling bussiness method on the same instance,the value of public variable is 0 instead of the populated value.
Is it normal to call unsetEntityContext() initially before ejbFindByPrimaryKey().What can be the problem.
Pls advise me.
sample code
public myBean implements EntityBean
{
priavate EntityContext ctx;
public int balance;
public void setEntityContext(EntityContext ctx)
{
System.out.println("Inside setContext");
this.ctx=ctx;
}
public void unsetEntityContext()
{
System.out.println("Inside unsetContext");
ctx=null;
}
public myPK ejbFindByPrimaryKey(myPK pk)
{
//making database connection through DataSource.Taking
//balance from database
System.out.println("Inside PrimaryKey");
this.balance=rs.getInt(1);
System.out.println("Balance is----="+balance);
//here i am getting balance 5000 from database
}
//BussinessMethod
public int getBalance()
{
System.out.println("Inside getBalance");
return balance;
}
}
the output i am getting is
inside setContext//here context shows primarykey=null
inside unsetContext
inside primarykey
balance is 5000
inside ejbload
inside getBalance
//here i am getting balance=0 ? Why i am not getting.It should be 5000.
if anybody can find solution pls guide me.