-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Sincronize problem. Store and find
PostPosted: Mon Dec 12, 2011 10:43 am 
Newbie

Joined: Wed Dec 29, 2010 8:58 am
Posts: 10
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.