Results 1 to 3 of 3

Thread: LazyInitializationException in Hession+Hibernate

  1. #1
    Join Date
    Aug 2004
    Posts
    2

    Default LazyInitializationException in Hession+Hibernate

    I am developing a Http-based service application adopting Hessian and Hibernate. But when trying to use detached Hibernate object in client side, I got LazyInitializationException all along. From Spring Reference Guide, I knew it's one bug of Hessian as it can't support the complex Hibernate Objects with Collection properties. However, it is very common to have to map out such Hibernate Objects as there must be one-to-many association even in a tiny relational database. RMI are supposed to work nicely with these objects but are not firewall-friendly. The book of Manning in Hibernate suggest to use DTO. Does anyone have better idea for this issue?

  2. #2

    Default

    If you use the latest version of Hessian (not 2.x or the earlies 3.0.x), you can solve that by not including Hibernate on the client side. That you make the newInstance on the Hhibernate list fails, and Hessian would fall back on java.util.ArrayList.

    If you have to include Hibernate on the client side, there's a few ways you can solve your problem. You can either manage to have your domain object serialize with an ArrayList, or you can extend Hessian classes and add your own serializer for hibernate's list. To modify the hessian's serialization, in the list's setter, you can wrap it in a List implementation that delegates to the hibernate list (e.g. in a Collections.unmodificableList()). You could also use a combinaison of writeReplace/readResolve, that's that would need to create something like a DTO to implement that I guess.

    However, if you want to use Serilization and HTTP, you can use Spring's new HttpInvoker, that's in the org.springframework.remoting.httpinvoker package.

    Guillaume

  3. #3
    Join Date
    Aug 2004
    Posts
    2

    Default Great, the domain objects now can beuse as Transfer Objects

    HI Guillaume

    Many thanks to your informative comment!!

Similar Threads

  1. Replies: 5
    Last Post: Dec 27th, 2005, 07:00 AM
  2. Loosing my SecureContext
    By sklakken in forum Security
    Replies: 3
    Last Post: Jul 21st, 2005, 01:44 PM
  3. Replies: 3
    Last Post: Nov 19th, 2004, 07:16 PM
  4. Replies: 9
    Last Post: Sep 25th, 2004, 12:35 PM
  5. Replies: 7
    Last Post: Aug 21st, 2004, 03:42 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •