Env: Hibernate 3.0.5 and MySQL 4.0.21 on MacOS X 10.4.2, running in Tomcat 5.
I am having small issue where my Object seems to to have a different attribute value every time I do a query on it, after having updated its value. For example, if I update the value 5 times and then do a query 10 times, then returned value is akin to a random value in the previous values it had been set to. The attribute I am interested in my examples is 'status'.
This is really freaking me out and is proving to be a major block for me.
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>
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();
}
BTW I have tried playing around with the values of Session.setCacheMode(), to no avail.
Any ideas??