[JBossWS] - avoid lazy-initialization exceptions
by mazz@jboss.com
We have a pretty big problem that I was hoping to get some feedback on how others solved the problem. Its a common-enough problem that I think others must have run into this.
We've got some SLSBs that return EJB3/JPA entities. We've annotated our SLSBs with @WebService so we can have a python client call into the SLSB via the web service interface.
Some of the SLSB methods return entities that are not fully, eagerly loaded. That is, for performance reasons, we don't need to eagerly load in all relationships before the SLSB returns the entity to the web service client.
However, when the web service container attempts to encode the entity in its XML representation, it calls the getters for those relationships we haven't loaded. This, in turn, throws the infamous LazyInitializationException.
Clearly, the answer is not to force web service apps to eagerly load all entity relationships. However, for maintenance purposes, we don't want to have to create another layer of data-transfer objects just to support the web service stuff (the SLSB API works fine from a Java UI client - the only problem occurs when needing web service access since this only happens when the web service container needs to encode the returned entity in XML).
Is there some way (annotation? configuration?) that we can tell the web service container to null out or otherwise not call the getters that we know won't work? Can we get the web service container to catch these lazy-init exceptions and just null out the XML value when returning the entity to the client?
How do others solve this problem?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4096654#4096654
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4096654
17 years