Announcement Announcement Module
Collapse
No announcement yet.
Transactional, Guaranteed Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Transactional, Guaranteed

    We use the Hibernate3 template from Spring. We recently fixed a couple of bugs where we were leaking connections from our connection pool, because the session factory was being by a bean that was NOT wrapped in side a transactional call (using TransactionProxyFactoryBean).

    What I would like, is for all such uses of SessionFactory to fail early, as a safety precaution against bad Spring configurations. Is there anyway to cause this failure supported directly in Spring?

    Thanks
    David

  • #2
    Originally posted by dcorbin13 View Post
    We use the Hibernate3 template from Spring. We recently fixed a couple of bugs where we were leaking connections from our connection pool, because the session factory was being by a bean that was NOT wrapped in side a transactional call (using TransactionProxyFactoryBean).

    What I would like, is for all such uses of SessionFactory to fail early, as a safety precaution against bad Spring configurations. Is there anyway to cause this failure supported directly in Spring?

    Thanks
    David
    David,

    There is no out-of-the-box solution (or I don't know about the one). However, you can simply achieve that yourself via adding a simple aspectj 'before' aspect that tracks all SessionFactory calls from your code and checks if spring transaction is active at the moment.

    So, that aspect may be applied at DEV environment to prevent such kind of errors early and be absent at PROD environment.

    Comment


    • #3
      Originally posted by denis.zhdanov View Post
      David,

      There is no out-of-the-box solution (or I don't know about the one). However, you can simply achieve that yourself via adding a simple aspectj 'before' aspect that tracks all SessionFactory calls from your code and checks if spring transaction is active at the moment.

      So, that aspect may be applied at DEV environment to prevent such kind of errors early and be absent at PROD environment.
      Thanks

      Can you tell me how to tell that a spring transaction is active? The only way I can imagine is to add additional aspects on a transactionProxyFactory that set's and clears thread local data.

      Comment


      • #4
        It's possible that "TransactionSynchronizationManager.isActualTransac tionActive()" might do this for you.

        Comment

        Working...
        X