-->
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: Inconsistent values after update
PostPosted: Thu Sep 29, 2005 12:26 pm 
Beginner
Beginner

Joined: Wed Sep 21, 2005 12:02 am
Posts: 31
I am having small issue where my Object seems to to have a different value every time I do a query on it, after having updated one of its columns. This is really freaking me out.

The code I am using to do the query is:
Code:
      Criteria criteria = session.createCriteria(Reservation.class);
      criteria.addOrder(Order.asc("time"));
      criteria.add(Expression.ge("date",startDate));
      criteria.add(Expression.le("date",endDate));

and the resulting query is:
Code:
Hibernate: select this_.id as id0_, this_.title as title2_0_, this_.description as descript3_2_0_, this_.startdate as startdate2_0_, this_.enddate as enddate2_0_, this_.starttime as starttime2_0_, this_.endtime as endtime2_0_, this_.allday as allday2_0_ from closeddates this_ where this_.startdate<=? and this_.enddate>=?

and the mapping file is as follows:
Code:
<hibernate-mapping>
   <class name="myco.domain.Reservation" table="reservations">
      
      <id
         name="key"
         column="id"
         type="integer">
         <generator class="native"/>
      </id>      

      <property
         name="date"
         column="resDate"
         type="date"/>
      <property
         name="time"
         column="resTime"
         type="time"/>
      <property
         name="partySize"
         column="pax"
         type="integer"/>
      <property
         name="tableSize"
         column="tableSize"
         type="integer"/>   
      <property
         name="tableNumber"
         column="tableNumber"
         type="integer"/>
      <property
         name="smoking"
         column="smoking"
         type="boolean"/>               
      <property
         name="walkin"
         column="walkin"
         type="boolean"/>   
      <property
         name="status"
         column="status"
         type="integer"/>   
      <property
         name="comments"
         column="comments"
         type="string"/>      
      
      <many-to-one
           name="guest"
           column="guestId"
           class="myco.domain.Guest"
           fetch="join"
           lazy="true"/>
           
   </class>   
   
</hibernate-mapping>


the attribute that is inconsistent in the result in "status". Any ideas?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 29, 2005 12:40 pm 
Beginner
Beginner

Joined: Wed Sep 21, 2005 12:02 am
Posts: 31
Just to add to my original post. I am using Hibernate 3.0.5 and MySQL 4.0.21. Also when I say incosistent I mean that every time I query the database the status attribute is any of previous values that the status had been. I also check and this is all using the same session. If I modified the value five times and then do a query involving that object 10 times the value returned is any of the five previous values.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 29, 2005 12:51 pm 
Beginner
Beginner

Joined: Wed Sep 21, 2005 12:02 am
Posts: 31
This is my update method:

Code:
  public void updateReservation (Reservation reservation) throws HibernateException{
    Transaction tx = null;
    Session session = null;   
    session = HibernateUtils.currentSession();
    tx = session.beginTransaction();     
    session.update(reservation);
    tx.commit();       
  }


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.