Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7577265
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T17:08:26+00:00 2026-05-30T17:08:26+00:00

I`m still in a learning stage with spring transactions and aop, and i have

  • 0

I`m still in a learning stage with spring transactions and aop, and i have some misundertandings :
1. if i do not use have an aop-advice and i specify for each service something like :

@Transactional(rollbackFor=java.lang.Exception.class,readOnly=true)

and then i look at spring log everything seems to work as expected. What i mean by this is that an transaction is created, and in case of exception i get a rollback. But if u use something like :

    <bean id="txManagerVA"  class="org.springframework.orm.jpa.JpaTransactionManager">
            <property name="entityManagerFactory"  ref="emfVA" />        
       </bean>

      <tx:annotation-driven transaction-manager="txManagerVA" />
<aop:config>
  <aop:pointcut id="transactionalServiceMethodsVA" expression="execution(* xxx.services.vs.*.*(..))"/>
  <aop:advisor advice-ref="txManagerVAAdvice" pointcut-ref="transactionalServiceMethodsVA"/>
</aop:config>

 <tx:advice id="txManagerVAAdvice" transaction-manager="txManagerVA">
    <tx:attributes>
     <tx:method name="get*" rollback-for="java.lang.Exception" read-only="true"/>    
     <tx:method name="*" rollback-for="java.lang.Exception" />   
    </tx:attributes>
 </tx:advice>

So, when i look at spring log,using this scenario, it seems that there are 2 transactions, on inside another, because after the rollback i get something like :

(IntermedServiceImpl.java:45) - WE HAVE AN EXCEPTION !!!! nullCrocodilu
(TransactionAspectSupport.java:406) - Completing transaction for [xxx.IntermedServiceImpl.getIntermed] after exception: java.lang.Exception: Crocodilu
(RuleBasedTransactionAttribute.java:130) - Applying rules to determine whether transaction should rollback on java.lang.Exception: Crocodilu
(RuleBasedTransactionAttribute.java:147) - Winning rollback rule is: RollbackRuleAttribute with pattern [java.lang.Exception]
(AbstractPlatformTransactionManager.java:935) - Triggering beforeCompletion synchronization
(TransactionSynchronizationManager.java:243) - Removed value [org.springframework.orm.jpa.ExtendedEntityManagerCreator$ExtendedEntityManagerSynchronization@63fd1f47] for key [org.hibernate.ejb.EntityManagerImpl@4eb35bed] from thread [thread-pool-1-8080(6)]
(AbstractPlatformTransactionManager.java:843) - Initiating transaction rollback
//SO FAR SO GOOD
(JpaTransactionManager.java:533) - Rolling back JPA transaction on EntityManager [org.hibernate.ejb.EntityManagerImpl@b3fbd77]
(AbstractPlatformTransactionManager.java:964) - Triggering afterCompletion synchronization
(TransactionSynchronizationManager.java:331) - Clearing transaction synchronization
(TransactionSynchronizationManager.java:243) - Removed value [org.springframework.orm.jpa.EntityManagerHolder@45a27493] for key [org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean@7ed30037] from thread [thread-pool-1-8080(6)]
(JpaTransactionManager.java:593) - Closing JPA EntityManager [org.hibernate.ejb.EntityManagerImpl@b3fbd77] after transaction
(EntityManagerFactoryUtils.java:343) - Closing JPA EntityManager
--> (AbstractPlatformTransactionManager.java:1012) - Resuming suspended transaction after completion of inner transaction <--
(TransactionSynchronizationManager.java:272) - Initializing transaction synchronization
(TransactionAspectSupport.java:406) - Completing transaction for [xxx.IntermedServiceImpl.getIntermed] after exception: java.lang.Exception: Crocodilu
(RuleBasedTransactionAttribute.java:130) - Applying rules to determine whether transaction should rollback on java.lang.Exception: Crocodilu
(RuleBasedTransactionAttribute.java:147) - Winning rollback rule is: null
(RuleBasedTransactionAttribute.java:152) - No relevant rollback rule found: applying default rules
(AbstractPlatformTransactionManager.java:922) - Triggering beforeCommit synchronization
(AbstractPlatformTransactionManager.java:935) - Triggering beforeCompletion synchronization
(AbstractPlatformTransactionManager.java:752) - Initiating transaction commit
(JpaTransactionManager.java:507) - Committing JPA transaction on EntityManager [org.hibernate.ejb.EntityManagerImpl@405c9cef]
(AbstractPlatformTransactionManager.java:948) - Triggering afterCommit synchronization
(AbstractPlatformTransactionManager.java:964) - Triggering afterCompletion synchronization
(TransactionSynchronizationManager.java:331) - Clearing transaction synchronization
(TransactionSynchronizationManager.java:243) - Removed value [org.springframework.orm.jpa.EntityManagerHolder@1f0cf366] for key [org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean@6012b597] from thread [thread-pool-1-8080(6)]
(JpaTransactionManager.java:593) - Closing JPA EntityManager [org.hibernate.ejb.EntityManagerImpl@405c9cef] after transaction
(EntityManagerFactoryUtils.java:343) - Closing JPA EntityManager

as you can see there i have marked the line that i do not understand.

And the second issue: in the same log file i`ve noticed a line like :

(JpaTransactionManager.java:407) - Not exposing JPA transaction [org.hibernate.ejb.EntityManagerImpl@b3fbd77] as JDBC transaction because JpaDialect [org.springframework.orm.jpa.DefaultJpaDialect@77acf1c0] does not support JDBC Connection retrieval

and i’ve googled a little bit and after added this :

<property name="jpaVendorAdapter">
        <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
            <property name="databasePlatform" value="org.hibernate.dialect.MySQL5InnoDBDialect" />
        </bean>
   </property> 

entitymanager bean, now it seems that jpa expose the transaction to jdbc transaction.
The problem is that i do not know what are the advantages/disadvantages of this configuration.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T17:08:28+00:00Added an answer on May 30, 2026 at 5:08 pm

    It seems that the problem was that i used both xml transaction configuration (aop part) and annotation transaction configuratio (@Transactional(rollbackFor=java.lang.Exception.class,readOnly=true)) part. If i remove the annotation everything works ok.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm still in the beginning stage of learning c#, so i have a question
I am learning and designing a WCF service. I have picked to use Windows
Still learning JSP Web Applications here. I have been doing this for a while
I'm still at the early stages of learning WPF and have decided to try
Please keep in mind I'm still in the early learning stage of jQuery. Having
Ok I am still having some issues with this code below. I have received
I'm still learning jQuery and would appreciate some pointers with this, as I think
I'm still at the learning stage of c# so don't shoot me if you
Still learning magento coding. I wonder is there a way I can print out
Still learning Objective-C / iPhone SDK here. I think I know why this wasn't

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.