I am more than a little confused about how transactions and beans work and would appreciate some help.
Imagine an entity bean that (for simplicity) represents a row in a relational DB. Further imagine that several clients have remote references to this data through several entity beans at the same time.
If a change is made to the bean by one of the clients, what effect does that have on the other beans for each of the transaction isolation levels when another client tries to update the bean or just obtain data from it ?
Or have a completely missed something here which is very likely indeed :-)
From what I understand about entity beans, there will be one entity bean instance for each record in a table in the database. For e.g assume that there is table called Employee with a corresponding entity bean EmployeeBean.
Assume that a new employee needs to be added to the Employee table. The client application (ususally a session bean) will be invoking the create method of EmployeeHome interface which would create an EmployeeBean instance and return a reference to its remote interface (say Employee) which then can be used to invoke the business methods. When a reference is made by some other client henceforth (it can be done by employee id - primary key) the client will get a reference to the existing entity bean which is synchronized with all the changes in the database.
I hope this clarifies your doubt
I had a look at the spec a bit more today and it does indeed say that there are two ways of handling this. The container could have one single instance of an entity bean with multiple clients 'taking turns' so to speak. Or, the could be several entity beans representing the same entity (ie same primary key value and data) with the underlying persistance manager taking care of concurrency and transaction isolation.
(See section 9.6.10 of the EJB2Beta specification)