Announcement Announcement Module
No announcement yet.
When to use PROPAGATION_SUPPORTS with Hibernate? Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • When to use PROPAGATION_SUPPORTS with Hibernate?

    I'm wondering when it would be a good idea to use PROPAGATION_SUPPORTS transaction propagation.

    I have the following transaction attributes for my get methods:

    The idea behind this was to have the read-only flag be a hint so that Hibernate does not try to detect and flush changes in the read-only transaction.
    However, I noticed that TransactionAspectSupport.createTransactionIfNecess ary() never creates a transaction when using PROPAGATION_SUPPORTS (which is logical), so the read-only hint is never given to Hibernate!

    The Hibernate community seems to say: "always use transactions", so I guess I should be using PROPAGATION_REQUIRED,readOnly for my get methods to make sure the read-only hint is properly used?