Hibernate version:3.2.6
mysql version:5.0
I create a simple table names person.
CREATE TABLE `person` (
`PERSON_ID` int(11) NOT NULL auto_increment,
`AGE` int(4) NOT NULL,
`FIRSTNAME` varchar(20) default NULL,
`LASTNAME` varchar(20) default NULL,
PRIMARY KEY (`PERSON_ID`),
KEY `person_firstname_lastname` (`FIRSTNAME`,`LASTNAME`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1;
mapped with pojo Person.
there are 3 records in the table.
1 18 Foo Bar
2 18 Foo Bar
3 18 Foo Bar
now , i use hibernate hql to select data
///////////////////////////////////////////////
int i=0;
while(true)
{
Session session = HibernateUtil.getSessionFactory().getCurrentSession();
String hsql= "from Person as person where person.age=18 ";
session.beginTransaction();
i++;
if (i >= 10) break;
Query queryObject = session.createQuery(hsql);
List originalList = queryObject.list();
System.out.println("size of list "+originalList.size());
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
HibernateUtil.getSessionFactory().close();
////////////////////////////////////////////////
the program last about 50 seconds. while the program is running, i use mysql command to update one record. update person set age where person_id=1; commit;
but the result from hql is still 3 records.(it should be 2).
what's wrong?
|