[jboss-user] [Persistence, JBoss/CMP, Hibernate, Database] - LazyInitializationException when serialize entity in SOAP(XM

jktinoco do-not-reply at jboss.com
Sat Sep 15 12:51:40 EDT 2007


Hi,
There are a common problem, when entities are linked in @OneToMany relationships with FetchType.LAZY attribute always a LazyInitializationException occurs when XML serializer tries to serialize it.

I think this happens because the XML serializer always access all entity's attributes and because the entity is attached to the hibernate's entity manager when XML serializer tries to serialize it.

LAZY fetch is very useful when we need to retrieve only some data from an entity and avoid to load all collections it have, if we use EAGER fetch all works perfectly but performance is seriously affected.

This behavior force to the developer to use ValueObject or Data Transfer Object pattern to avoid this problem, frequently developers need to transfer across the wire in SOAP protocol many entity objects and use one Value Object for every entity is expensive, it would be better use directly only entity beans.

Maybe if hibernate let us detach manually entities from the entity manager this problem go away and life can be more simple.

BEA introduces this extension in your implementation of JPA, Hibernate and JBoss could do it too.

If someone knows how i can avoid to use Value Objects in entities with LAZY fetch to serialize in SOAP your help will be very appreciated.

Thanks!!

Jair

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

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



More information about the jboss-user mailing list