-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: LazyInitialisation, around aspect, log error in constructor
PostPosted: Sun Aug 27, 2006 9:22 pm 
Newbie

Joined: Wed Jan 14, 2004 4:44 pm
Posts: 13
Location: Wellington, New Zealand
What do people think about this:

I would like to be able to load a domain object, pass it to the view, and enable the view to traverse the domain object graph without any knowledge of the persistence machanism (Hibernate).

In web applications, the "Open Session in View" is an option, but this option doesn't apply for a standalone application with a Swing/SWT GUI.

Another option is to use around advice, with a pointcut that catches calls to domain accessor methods. The advice would attempt to proceed with the method, if the method throws a LazyInitializationException, a new Hibernate Session would be obtained, the domain object on which the accessor method is being invoked would be reattached to the new Session, and the method would be attempted again, and should succeed. Of course, the domain object has no knowledge of the persistence of its collaborators:

domainObject1.getDomainObject2();

This should work nicely, as someone has indicated here:

http://www.jroller.com/page/cenkcivici?entry=reattaching_lazy_objects_to_hibernate

The only problem, as noted at the same URL, is that the constructor for LazyHibernateException logs an error message. Two JIRA issues to have this log statement removed have been turned down: HHH-2025, HB-1363.

So what do people think? Is this a legitimate use of LazyInitializationException / Hibernate Session? Is this reason enough to remove the log statement in the LazyInitializationException constructor?

Cheers

Russell


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.