[jboss-user] [EJB 3.0] - EJB3 transaction / lazy loading issue

zilbi do-not-reply at jboss.com
Wed Aug 13 13:17:35 EDT 2008


got an entity with a few lazy collections in it.
also got a stateless session bean that uses this entity in an ejb method. the method does no changes to the entity, only reads the entity's data and returns it.

now if i use:
i get the notorious lazy load exception problem when i try to invoke getters of the entity's lazy collection. so i remove the attribute at all or use the @TransactionAttribute(TransactionAttributeType.NOT_REQUIRES_NEW) attribute instead.

the thing is that i then see in the server log that hibernate is invoking an update query on the entity. the query updates all the entity's fields (not the lazy collections) by primary key field as well as version field.
the update SQL together with commit takes around 20-40 milliseconds which is just too much for me.

why is the update being performed?
is there a way to prevent it (since i know for sure i do not need it)?
is there a way to enjoy lazy load without opening a transaction? (a sort of a read only trx..)


View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4170384#4170384

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4170384

More information about the jboss-user mailing list