0

I'm working on Java Spring Hibernate Project with mysql.

I'm trying to make some insert in cascade. The jobs are thrown on a cluster so they can occurs nearly at the same time and so there is a Deadlock problem.

I have this error :

Deadlock found when trying to get lock; try restarting transaction

I found here that there is @RetryTransaction for spring developper. A way to configure here.

They say that :

The method's class must be woven (either at build time or runtime) using the AspectJ compiler with the RetryTransactionAspect aspect (included in the dellroad-stuff JAR file).

What does it mean ?

But i don't succeed to make it work. It never restart the transaction. What am i missing ?

Thanks !

@Override
@RetryTransaction
@Transactional
public void save(AnalyseResult analyseResult){

    @SuppressWarnings("deprecation")
    final int attempt = RetryTransactionAspect.getAttempt();

    System.out.println("#############");
    System.out.println("Retry Transact : "+attempt);
    System.out.println("#############"); 

    analyseResultDao.save(analyseResult);
}

In my BeanConfig.xml :

<bean class="org.dellroad.stuff.spring.RetryTransactionAspect" factory-method="aspectOf">
     <property name="persistenceExceptionTranslator" ref="hibernateExceptionTranslator"> </property>
    <property name="maxRetriesDefault" value="4"></property>
        <property name="initialDelayDefault" value="25"></property>
        <property name="maximumDelayDefault" value="5000"></property>
</bean>
Community
  • 1
  • 1
ZheFrench
  • 1,164
  • 3
  • 22
  • 46
  • Do you have the AspectJ JAR's on your classpath? I'm going to assume so. I'd have a look and see if there is any Hibernate documentation because I imagine that you would need to configure the Hibernate transaction manager with AspectJ. – JamesENL Jun 11 '14 at 01:48
  • I handle with maven Aspectjrt.1.5.4 & aspectjweaver.1.5.4. So they are in the classpath. Do you mean i have to add some config as this : ? – ZheFrench Jun 11 '14 at 17:38

0 Answers0