-->
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.  [ 3 posts ] 
Author Message
 Post subject: About Hibernate's SQL execute order
PostPosted: Mon Jun 21, 2004 10:04 pm 
Newbie

Joined: Mon Jun 21, 2004 9:56 pm
Posts: 4
I have code like these:

Code:
    if (user.getPasswd().equals(passwd)) {
   user.setStatus("Login");
   System.out.println("1-------------");
   officerDAO.update(user);
            
   }
   SysLog sLog = new SysLog();
   sLog.setOfficerCode(user.getOfficerCode());
   sLog.setDetail("Test system log.");
   System.out.println("2-------------");
   sysLogDAO.save(sLog);


And output is :

Code:
1-------------
Hibernate: update Officer set officerCode=?, name=?, password=?, status=? where oid=?
2-------------
Hibernate: insert into SysLog (operDate, officerCode, detail, type, eid) values (?, ?, ?, ?, ?)


that is correct.
but when I declare transaction in applicationContext-hibernate.xml like:

Code:
   <bean id="loginService" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">   
      <property name="transactionManager"><ref local="myTransactionManager"/></property>
      <property name="target"><ref local="loginTarget"/></property>
      <property name="transactionAttributes">
         <props>
            <prop key="find*">PROPAGATION_REQUIRED,readOnly,-officerException</prop>
            <prop key="login*">PROPAGATION_REQUIRED</prop>
         </props>
      </property>
   </bean>


the output become:

Code:
1-------------
2-------------
Hibernate: insert into SysLog (operDate, officerCode, detail, type, eid) values (?, ?, ?, ?, ?)
Hibernate: update Officer set officerCode=?, name=?, password=?, status=? where oid=?


WHY ?? the SQL execute order changed too.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 22, 2004 12:07 pm 
Newbie

Joined: Mon Jun 21, 2004 9:56 pm
Posts: 4
How can I prevent this?
The order of SQL execute is very important.


Top
 Profile  
 
 Post subject: Re: About Hibernate's SQL execute order
PostPosted: Thu Nov 19, 2009 3:50 am 
Newbie

Joined: Sun May 22, 2005 10:15 pm
Posts: 1
Location: Beijing, China
use session.flush() after you invoke the save or update method.


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

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.