Imran, When your code enters the EJB tier, the entry point has some Transaction semantics defined in the deployment descriptor. If that semantic states that a transaction is required then the container will begin a new transaction. Since you begin a new transaction in the Session Bean (which is presumably the entry point into the EJB tier for the business function), when you invoke the code to set the attribute of the entity bean (which also requires a transaction), your transaction requirements have already been satisfied, i.e., you are already in a transaction. Now comes the less obvious part. After you have set the attribute in the entity bean, within the same transaction (the transaction in which you modified the entity bean has not been committed nor aborted yet), you call a finder method on the entity's home interface. This produces a second, fresh instance in memory of the entity that you have just modified, with its attributes set from the values in the database as of the current transaction. You see, you've made a change to the in memory representation of a persistent object, then you go read the object again from the database without committing your chagne. If you want the update to the entity's state to be retrieved by a subsequent query, you will need to commit the change before doing the read. In general, if you've already read an entity bean in any given transaction, you don't want to read it a second time. See if there's a way to pass the instance of the bean that you already have rather than invoke a finder method.
Cheers, Richard Doust -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf Of Imran Bohoran Sent: Thursday, January 03, 2002 12:23 PM To: Jboss-User (E-mail) Subject: [JBoss-user] Transaction problem Hi all I'm facing a problem which I believe many of you would be having some solution. I have a session bean which is deployed with the TRANSACTION attribute as "Required" and entity beans with the TRANSACTION attribute as "Required" for all the methods. I'm setting a value on a entity from my session bean to the entity A. soon after that I'm calling a private method which does a finder on entity A which should include the value added above. But, my finder is not returning the data that I've added. What could it be that I'm missing here.? Appreciate any quick response TIA and Cheers Imran _______________________________________________ JBoss-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-user _______________________________________________ JBoss-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-user
