-->
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.  [ 2 posts ] 
Author Message
 Post subject: Query objects using 'select * from ...', is it possible?
PostPosted: Mon Sep 22, 2008 6:32 am 
Newbie

Joined: Mon Sep 22, 2008 6:16 am
Posts: 2
Hi,

May be this is a simple question... but I'd searched for a while and found nothing about it.

When you query for objects using HQL, for example "from Car c where c.year>?", Hibernate uses two SQL statements:
* The very first one retrieves the Id's of the resulting records:
SELECT CAR_ID FROM CARS WHERE CAR_YEAR>?

* The second one retrieves all the fields of each record whenever it is accessed:
SELECT CAR_MODEL, CAR_COLOUR, CAR_YEAR FROM CARS WHERE CAR_ID=?

Is it possible to instruct Hibernate to get an object in a "one-shot" SQL? I mean, is it possible for Hibernate to issue a single SQL statement like:
SELECT * FROM CARS WHERE CAR_YEAR>?

Thanks in advance!


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 22, 2008 6:54 am 
Newbie

Joined: Mon Sep 22, 2008 6:16 am
Posts: 2
Self-answer my own question...

It looks that Hibernate issues two SQL's if I use Query.iterate() method, but behaves exactly as I want to if I use Query.list()...

... so this it!! :-)

Should have investigated further before asking :-(

Thanks a lot!!


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

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.