-->
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: Hibernate3 criteria query returns stale count against hsqldb
PostPosted: Tue Mar 13, 2012 10:56 am 
Newbie

Joined: Tue Mar 13, 2012 10:46 am
Posts: 1
Hibernate criteria query is returning me stale results.

I have a simple table ApplicationLog in Hsqldb 1.8.0

A seperate client inserts data into this table.

I am querying this table from another java client.
I find that the criteria query count is not correct if this querying java client is left running.(i.e if the inserts happen via the other client , when I query I dont see those results - the other client does commit and I can view the inserted statements from a sql client - only my hsql client has problems viewing the new data)

If I close the client and restart it the data returned.

Here is my code for querying:

SessionFactory sessionFactory = HibernateConfigurer.getFactory();

Session session = sessionFactory.openSession();
Criteria criteria = session.createCriteria(
ApplicationLog.class).setCacheMode(CacheMode.IGNORE);

if(keys != null)
{
int size = keys.length;

Long[] allKeys = new Long[size];
for (int i = 0; i < size; ++i)
{
allKeys[i] = new Long(keys[i]);
}

criteria.add(
Restrictions.in(
"applicationLogItemKey", allKeys));
}

if((from != null) && (to != null))
{
criteria.add(Restrictions.ge(
"logTime", from));
criteria.add(Restrictions.le(
"logTime", to));
} else {

if(from != null) {
criteria.add(Restrictions.ge(
"logTime", from));
} else if(to != null) {
criteria.add(Restrictions.le(
"logTime", to));
}

}

criteria.setFirstResult(startNumber);
criteria.setMaxResults(pageSize);
criteria.addOrder(Order.desc("logTime"));

List applicationLogs = criteria.list();

session.close();
return applicationLogs;

I tried different cache modes thinking I am only hitting the cache.
I also tried evicting the class in question. But nothing helps. I see only stale data and not the newly inserted data unless I restart my client.

Can someone help please.


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.