-->
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: Generated SQL-statements for Criteria.uniqueResult
PostPosted: Thu Mar 25, 2010 12:41 pm 
Newbie

Joined: Fri Feb 26, 2010 9:09 am
Posts: 10
When I use this code to read a single object from the database:
Code:
Criteria crit = sessionFactory.getCurrentSession().createCriteria(entityName);
crit.add(Restrictions.idEq(id));
Object ret = crit.uniqueResult(); 

sessionFactory.getCurrentSession().clear();



It results in the following SQL-statements:
Code:
select count(*) as y0_ from <TABLE_NAME> this_ where this_.ID='id1'

select * from ( select this_.ID as PK1_235_0_, this_.ATTR1...... from  <TABLE_NAME>  this_ where  this_.ID='id1' order by this_.ID asc ) where rownum <= 100



Can anyone tell me why
- the first statement (select count(*)...) is generated by hibernate and
- the second statement includes "where rownum <= 100" - since only one object is read ???



I'm using Hibernate 3.3.1 GA with Mappings (no Annotations) and an Oracle 10 database.


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.