Are you tired of banging your head against wall because of the infamous LazyInitializationException? You're not the only one. Exposing your EJBs that return JPA entities as a web service is really bugging most developers crazy.
Or are hibernate entity objects shouldn't be used as a return type for any web methods in a web service? This is not only applicable to web services, it is also applicable to all scenarios where the entity bean is being inspected during marshaling and unmarshalling.
For more information, read the articles below:
http://www.techienuggets.com/Detail?tx=15869https://forum.hibernate.org/viewtopic.php?f=1&t=971390&p=2342092&hilit=LazyInitializationException+WebService#p2342092Perhaps maybe hibernate is not really meant for web services if you're using FetchType=LAZY yeah? Or you might provide your boiler plate for iterating the whole object graph and setting null all properties that are proxies, and if you're working on an EJB, you will be forced to use bean managed transaction to do this.
Is there an elegant solution to this most ignored hibernate problem? Anyone?