|
From: <jue...@we...> - 2004-09-24 17:37:44
|
Well, HibernateInterceptor is an AOP Interceptor: Its very point is to = bind a Hibernate Session to the thread. In other words, it would be = completely pointless to not bind a Session there, because the = interceptor wouldn't to anything then. HibernateTemplate on the other hand is supposed to execute a given = HibernateCallback, respectively the internal callbacks for the shortcut = methods - nothing else. It is not necessary to bind a Session to the = thread for this, therefore HibernateTemplate doesn't do so. Nested HibernateTemplate calls would be somewhat strange anyway: A = HibernateCallback that in turn delegates to some other class that in = turn uses HibernateTemplate again? I don't think that this is really = common. Do you have a concrete use case for this? Note that JdoTemplate, JdbcTemplate, etc all behave the same in that = respect: None of those binds anything to the thread for the duration of = its execute methods. Just the special interceptors for Hibernate and JDO = do so, mainly for use with JtaTransactionManager. In total, I'd like to keep the current behavior. Remember that you're = supposed to perform all data access within transactions anyway, so all = that talk about non-transactional Sessions is nonsense and useless = noise. "There is no such thing as a non-transactional Session." ;-) Juergen -----Original Message----- From: spr...@li... [mailto:spr...@li...]On Behalf Of Colin Sampaleanu Sent: Friday, September 24, 2004 6:59 PM To: spr...@li... Subject: [Springframework-developer] Why does HibernateInterceptor bind Session always, while HibernateTemplate only if there is a tx? Juergen, I was poking around in the HibernateInterceptor and HibernateTemplate=20 code following a forum post, and unless I'm missing something,=20 HibernateInterceptor (correctly) binds the new Session that is created=20 to the current thread even if there is no transaction already existing=20 to synchronize to, but on the other hand, on the execute() call=20 HibernateTemplate will only bind the Session to the thread if=20 transaction synchronization is active. Am I missing something? If this=20 is correct, this does not seem appropriate to me, as HibernateTemplate=20 should be (and is listed in the JavaDocs) as the programattic equivalent = of HibernateInterceptor, and nested HibernateTemplate calls should=20 utilize a thread-bound session put there by the outermost one,=20 regardless of transaction settings, not create a new Session. Am I missing something? Colin ------------------------------------------------------- This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one of 170 Project Admins to receive an Apple iPod Mini FREE for your judgement on who ports your project to Linux PPC the best. Sponsored by IBM. Deadline: Sept. 24. Go here: http://sf.net/ppc_contest.php _______________________________________________ Springframework-developer mailing list Spr...@li... https://lists.sourceforge.net/lists/listinfo/springframework-developer |