We are using BMP and have a service bean call a business method from an Entity bean. We find that the return value is by call-by-reference, that is what the service bean obtained is actally the same instrance stored in the entity bean.
We are using commit option 'A' and remote interface (not local interface), why this situation will happen ? and how to disable it?
sample code ... a method in the service bean ..
/*********************/
Context ctx = JBossContext.getContext();
Object obj = ctx.lookup("ejb/ZDMDocumentsEB");
com.dms.ejb.entity.ZDMDocumentsEntityRemoteHome homeInterface =
(com.dms.ejb.entity.ZDMDocumentsEntityRemoteHome) javax.rmi.PortableRemoteObject.narrow(obj, com.dms.ejb.entity.ZDMDocumentsEntityRemoteHome.class);
ZDMDocumentsEntityRemote remote = (ZDMDocumentsEntityRemote)
homeInterface.findByPrimaryKey("804", "");
// (1) !! an object reference is return by the entity bean class
// This ojbject is a member of the entity bean class
// doc is a helper class
DocumentImpl doc = (DocumentImpl) remote.getEntityForView("");
// (2) we try to set another value
doc.setFiled("Set another value");
// (3) get the data again
DocumentImpl doc2 = (DocumentImpl) remote.getEntityForView("");
// STRANGE !! We find that 'doc' and 'doc2' are the same object !!
// and the modification on 'doc' is reflected on 'doc2' !!!!!
System.out.println("doc2 == doc " + (doc == doc2));
/*********************/
Please advice..
Thanks for your help!!