-
1. Re: Entity bean called from a session bean or directly from
pilhuhn Jun 22, 2004 1:49 PM (in response to raf)What is your transaction demarcation?
Are 3 and 4 executed in the same call to the SB and 5 before the call to this SB returns? -
2. Re: Entity bean called from a session bean or directly from
raf Jun 23, 2004 3:21 AM (in response to raf)3 and 4 executed in the same call to the SB but 5 is executed after the call to this SB returns.
I'm using the following client code:
===============================================
..........
InitialContext lContext = new InitialContext();
TestSessionHome lHome = (TestSessionHome) lContext.lookup( "ejb/TestSession" );
TestSession lSession = lHome.create();
// Get a new Id of the Test Entity
lSession.updateEntity(6,"pea");
lSession.updateEntity(6,"pix");
// Get Test Entity Remote Interface
//Context lContext = new InitialContext();
TestBMPEntityHome lHomeEntity = (TestBMPEntityHome) PortableRemoteObject.narrow(
lContext.lookup(
"ejb/TestBMPEntity"
),
TestBMPEntityHome.class
);
TestBMPEntityPK pk=new TestBMPEntityPK(6);
TestBMPEntity lEntity = lHomeEntity.findByPrimaryKey(pk);
TestBMPEntityData lDataEntity =lEntity.getValueObject();
System.out.println("first name: "+lDataEntity.getFirstName());
System.out.println("id: "+lDataEntity.getId());
===============================================
this is the called session bean method:
===============================================
/**
* @ejb:interface-method view-type="remote"
**/
public void updateEntity(int id, String name)
throws
RemoteException
{
try {
// Get Test Entity Remote Interface
Context lContext = new InitialContext();
TestBMPEntityHome lHome = (TestBMPEntityHome) PortableRemoteObject.narrow(
lContext.lookup(
"ejb/TestBMPEntity"
),
TestBMPEntityHome.class
);
TestBMPEntityPK pk=new TestBMPEntityPK(id);
TestBMPEntity lEntity = lHome.findByPrimaryKey(pk);
TestBMPEntityData lData = new TestBMPEntityData();
//lEntity.getValueObject();
lData.setFirstName(name);
lData.setId(id);
lEntity.setValueObject(lData);
}
catch ( Exception ive ) {
throw new EJBException( "exception: " + ive.getMessage() );
}
}
===============================================
The resulting System.out is (using v1=pea):
>first name: pea
>id: 6
anyway I can find the record changed on the database with name=pix.