Announcement Announcement Module
Collapse
No announcement yet.
programtic transation and declarative transaction Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • programtic transation and declarative transaction

    All my service classes are annotated with @Transaction , now in one of the methods I want to user hibernate batch update feature and hibernate batch updated feature needs programmatic transaction , please tell me can I have both declarative and programmatic transaction together ie disable declarative transaction and use programmatic transaction for a method ??

  • #2
    Sure why not, as long as you use springs approach and not the hibernate one. I suggest the reference guide.

    Comment


    • #3
      If I use sapring batch will I have to turn off hibernate second level cahce as hibernate recommends for using batch updates ?

      Comment


      • #4
        The problem with batch updates is that your 2nd level cache can get quickly out of sync with the database. Next to that if you have a lot of updates you might end up with your whole database in memory, that is why you should disable 2nd level cache when using batch updates.

        Comment


        • #5
          Originally posted by Marten Deinum View Post
          The problem with batch updates is that your 2nd level cache can get quickly out of sync with the database. Next to that if you have a lot of updates you might end up with your whole database in memory, that is why you should disable 2nd level cache when using batch updates.
          can you please give me an example of using programmatic transactions for a method in a class which is annotated with transaction ,
          any class annotated with @Transaction add transaction code to all methods , If one method as an exception has to use programmatic transaction what additional meta-information I should provide for this method so that this method is not wrapped in transaction code ?

          Comment


          • #6
            Well basically you have 2 options

            1) Annotate that method with @Transaction(propagation=NONE or NEVER) so no transaction is started, then simply use a transactiontemplate with the default settings to start a transaction at your will
            2) Simply let the @Transactional be an use the TransactionTemplate to start a new transaction (REQUIRES_NEW) instead of the default settings.

            Comment

            Working...
            X