Results 1 to 4 of 4

Thread: tx timeouts with HibernateTransactionManager vs JtaTransactionManager

  1. #1
    Join Date
    Mar 2005
    Location
    Tokyo, Japan
    Posts
    103

    Default tx timeouts with HibernateTransactionManager vs JtaTransactionManager

    I've read in Hibernate documentation as well as Spring doc that HibernateTransactionManager has, at best, a limited support of the transaction timeouts.

    about Transaction timeout in Hibernate doc:
    Outside a managed (JTA) environment, Hibernate cannot fully provide this functionality. However, Hibernate can at least control data access operations, ensuring that database level deadlocks and queries with huge result sets are limited by a defined timeout. In a managed environment, Hibernate can delegate transaction timeout to JTA.
    in Spring (though this might come from an older version of the doc)
    Supports custom isolation levels, and timeouts that get applied as appropriate Hibernate query timeouts. To support the latter, application code must either use HibernateTemplate (which by default applies the timeouts) or call SessionFactoryUtils.applyTransactionTimeout for each created Hibernate Query object.
    I'm quite unclear about whether the default timeout will be applied to at least what Hiberate doc calls "data access operations" if I use HibernateTemplate. It should according to the doc.
    We have timeouts problem with our application, and I just switched to using HibernateTemplate instead of my own template.
    Do you think that was a sufficient reason to have no timeout applied before? Will the switch to using HibernateTemplate be enough to enable it?

    What would be the cost to using JtaTransactionManager instea of HibernateTransactionManager?

    What could possibly be transactions that are not data access operations???

  2. #2
    Join Date
    Nov 2005
    Location
    Reutlingen, Germany
    Posts
    2,098

    Default

    Quote Originally Posted by Jean View Post
    Do you think that was a sufficient reason to have no timeout applied before? Will the switch to using HibernateTemplate be enough to enable it?
    Since HibernateTemplate is only a thin wrapper around the Hibernate API I would tend to trust the Hibernate documentation. It's a bit vague though. Probably only tests can assure correct working of timeouts.

    Quote Originally Posted by Jean View Post
    What would be the cost to using JtaTransactionManager instea of HibernateTransactionManager?
    If you are in a managed environment the switch should be quite easy, a configuration matter in Spring. If you are running in a plain servlet container you need some additional integration stuff like Jencks.

    JTA has for sure some overhead at runtime, but it should not be that much. Again only tests can give you exact numbers. Hibernate btw. recommends to always use JTA. Furthermore some JTA TransactionManager implementations apply optimizations if only one resource is to be controlled transactionally.

    Jörg

  3. #3
    Join Date
    Mar 2005
    Location
    Tokyo, Japan
    Posts
    103

    Default

    thanks Jorg,
    very informative. I didn't know Hibernate recommends to always use JTA.
    Jencks apears to be a good alternative for my non managed environment.

    Would you know a convenient way to test tx timeouts? Is there a specific exception thrown upon timeout? How to reproduce a lock on a resource?

    Jean

  4. #4
    Join Date
    Nov 2005
    Location
    Reutlingen, Germany
    Posts
    2,098

    Default

    Quote Originally Posted by Jean View Post
    I didn't know Hibernate recommends to always use JTA.
    It's mentioned on their web site and in the reference manual.

    Quote Originally Posted by Jean View Post
    Jencks apears to be a good alternative for my non managed environment.
    It's only one alternative - and the one I use. Atomikos is another one I'm aware of.

    Quote Originally Posted by Jean View Post
    Would you know a convenient way to test tx timeouts?
    Should be easily doable with putting the thread to sleep for a while. Of course this must happen after the transaction has been started.

    Jörg

Posting Permissions

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