-->
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.  [ 4 posts ] 
Author Message
 Post subject: How possible this update is not working?
PostPosted: Tue Mar 06, 2007 2:01 am 
Newbie

Joined: Wed Feb 07, 2007 7:55 pm
Posts: 18
I have read a quite few of other people's mysterious Hibernate problems on one forum. Now, I have my own few. Here is one of them.

Hibernate version:
3.2
Code between sessionFactory.openSession() and session.close():
Code:
      MyClass r = (MyClass) session.load(MyClass.class, i);
      r.setAttribute1(a1);
      session.flush();

The above code segment has been modified from the Spring HibernateDaoSupport class code.
Name and version of the database you are using:
PostgreSQL 8.1
The generated SQL (show_sql=true):
Code:
Hibernate:
    select
        my_class0_.id as id2_0_,
        my_class0_.producer_id as producer2_2_0_,
        my_class0_.trigger_date as trigger3_2_0_,
        my_class0_.content as content2_0_
    from
        bm_my_class my_class0_
    where
        my_class0_.id=?

I only see the above select statement, but not an insert statement. A similar updating code on another class works correctly. I fail to see any difference between these two updating, but one works while the other doesn't.

What can go wrong here?


Last edited by hm0 on Tue Mar 06, 2007 1:26 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 06, 2007 5:18 am 
Expert
Expert

Joined: Tue Nov 23, 2004 7:00 pm
Posts: 570
Location: mostly Frankfurt Germany
You are not commiting any transactions. Could you add this to your code.

_________________
Best Regards
Sebastian
---
Training for Hibernate and Java Persistence
Tutorials for Hibernate, Spring, EJB, JSF...
eBook: Hibernate 3 - DeveloperGuide
Paper book: Hibernate 3 - Das Praxisbuch
http://www.laliluna.de


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 06, 2007 12:41 pm 
Regular
Regular

Joined: Wed Aug 25, 2004 7:40 pm
Posts: 65
LaLiLuna wrote:
You are not commiting any transactions.

How do you explain the select statement is issued, but not the inserting one without the commit statement?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 06, 2007 1:34 pm 
Newbie

Joined: Wed Feb 07, 2007 7:55 pm
Posts: 18
LaLiLuna wrote:
You are not commiting any transactions. Could you add this to your code.


There isn't/shalln't any code on transaction commitment in a method of HibernateDaoSupport. The transaction is defined in a configure file as:
Code:
   <bean id="myClassDao" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
        <property name="transactionManager" ref="transactionManager"/>
      <property name="target">
         <bean class="com.abc.xyz.data.hibernate.HibernateMyClassDao">
              <property name="sessionFactory" ref="sessionFactory"/>
         </bean>
      </property>
      <property name="transactionAttributes">
         <props>
                <prop key="get*">PROPAGATION_REQUIRED,readOnly</prop>
                <prop key="create*">PROPAGATION_REQUIRED</prop>
                <prop key="update*">PROPAGATION_REQUIRED</prop>
                <prop key="delete*">PROPAGATION_REQUIRED</prop>
         </props>
      </property>
   </bean>

And the method name starts with "update".


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.