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.  [ 1 post ] 
Author Message
 Post subject: hibernate bug? hql can't detect data change by others
PostPosted: Sun Sep 14, 2008 9:45 am 
Newbie

Joined: Sun Sep 14, 2008 8:04 am
Posts: 1
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?


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

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.