Joost Kraaijeveld wrote:
> If I have a long lasting transaction in Stateless SessionBean during
> which I load an CMP EJB bean, how long is that EJB bean locked? From
> it's ejbLoad untill the total end of the transaction, even if I only
> call it's getters?
Yes, you are correct.
I avoid using entity beans, and that is one of the big reasons that I
avoid them.
You have a few options. First, it is possible that your particular
container (EJB server) provides a way to indicate that an entity bean
is "read only". Of course, this means that if you also need to update
the data you will need 2 EJBs: one that is read-only and one that is
read-write.
If you only need the entity bean for a short time, and later changes to
the entity data by other processes will not affect your main
transaction, you could cause the entity bean to be accessed in a
separate transaction which only lasts for as long as you need that
entity bean. This would probably involve a new session bean which
performs all of the entity bean access, with the business method marked
as RequiresNew.
Personally, instead of adding a session bean that access the entity
bean, I would create a session bean that accesses the database directly
with JDBC, and get rid of the entity bean entirely.


|