Hello, running some tests I have faced some problems.
When I try to store one object, which it has fixed id (not auto generated), I can not find it.
The process is:
Code:
public Concept storeIfNotExistsConcept(Concept conceptToTest) throws DataAccessLayerException{
// this.storeConcept(conceptToTest);
// return conceptToTest;
if(conceptToTest!=null)
{
Concept concept = findByID(conceptToTest.getUri());
if(concept == null){
concept = super.save(concept);
}
return concept;
}
return null;
}
And the problem occurs in the method find, if I change the process by the commented lines, it dissapear.
The class extends AbstractHibernateDAOSupport and the test itself has the annotation @Transactional, so all the operations to the ddbb happen in the same transaction.
Here my configuration:
Code:
<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<aop:aspectj-autoproxy proxy-target-class="true"/><!-- Se puede poner tb a nivel de bean -->
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="*" propagation="REQUIRED" />
</tx:attributes>
</tx:advice>
<aop:config>
<aop:pointcut id="serviceOperation"
expression="execution(* com.app.daoTests.**.*(..)) " />
<aop:advisor advice-ref="txAdvice" pointcut-ref="serviceOperation" />
</aop:config>
The error is:
Quote:
ERROR org.hibernate.event.def.AbstractFlushingEventListener - Could not synchronize database state with session
com.platform.services.exception.ServiceExecutionException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1; nested exception is org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1
I have tried to flush the transaction just after the save method, but more conflicts are coming.
Any help would be really appreciated! Thanks in advance