Hello Everybody!
I'm currently working with on a fat client application using a self written RMI server (10 years ago). The server sends EJB1.1/2.0 beans to the client who has full access to these remote objects. After commiting a transaction, all dirty beans are persisted by the server.
The plan is to replace the server by a JBoss5 & EJB3 without (massively) changing the client app (roughly 10000 class files). A typical client snip would be
UserTransaction tx = ClientCtxManager.getUserTransaction();
tx.begin();
DummyClassHome dummyHome = (DummyClassHome)lookup(DummyClassHome.class.getName());
DummyClass dummy = dummyHome.findByPrimaryKey(1234);
dummy.setValue("Hello World");
tx.commmit();
-> dummy persisted on the server.
On JBoss I use a stateless session bean for executing findByPrimaryKey. In this finder I lookup a RemoteInterface of a stateful session bean, which I would like to use to carry the entity to the client. Because of Serialization/Deserialization the entity looses the connection to the session which would be vital for commiting changes.
// DummyHome implementation
public MyClass findByPrimaryKey(BigDecimal pk)
{
Session s = HibernateUtil.getSessionFactory().getCurrentSession();
MyClassEntity temp = (MyClassEntity)s.get(MyClassEntity.class, (BigDecimal)pk);
// session.contains(temp) delivers true
MyClassRemote remote = (MyClassRemote)InitialContextFactory.getInitialContext().lookup("DemoEAR/MyClassBean/remote");
remote.setENTITY(temp); // set the member variable of the stateful session bean
//session.contains(remote.getENTITY()) delivers false
return remote;
}
Any suggestions would be appreciated!