-->
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.  [ 9 posts ] 
Author Message
 Post subject: Avoid listing all columns in SELECT clause
PostPosted: Mon Jun 14, 2004 4:02 pm 
Regular
Regular

Joined: Fri Mar 26, 2004 11:45 am
Posts: 75
I have a couple of tables with large numbers of columns. Hibernate lists all the solumns in the target tables when converting HQL to SQL. I remember there was a way to force Hibernate just to use "select * from ..." instead of listing all the columns in the SELECT clause. How do I do this?

Thanks.

Alec


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 14, 2004 6:17 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
select cat from Cat cat is somehow equlvalent to select * from CAT_TABLE

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 15, 2004 3:19 pm 
Regular
Regular

Joined: Fri Mar 26, 2004 11:45 am
Posts: 75
"select cat from Cat" HQL query will be translated to "select name, gender, age, from cat" SQL query.

What I need is and HQL query that would be translated into "select * from cat"! I remember there was a way to force Hibernate to use "select *" instead of listing all the columns, but can't remember how to do this.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 15, 2004 5:53 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Why do you want to do this?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 16, 2004 10:39 am 
Regular
Regular

Joined: Fri Mar 26, 2004 11:45 am
Posts: 75
I want to replace a list off columns in the SELECT clause with a * in order to reduce the size of the query sent to the DB server. By default Hibernate uses column names to retrieve data from the result set, so there is no need to list all columns in the SELECT clause anyway.
So, the question persists, how do I configure Hibernate to use "SELECT *" instead of "SELECT list_of_all_columns"

Thanks.

Alec


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 21, 2004 3:18 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
You cannot.
Hibernate has to use alias to correctly match columns to java properties.
Plus I'm not sure the column order is well known when you use *

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 21, 2004 3:26 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
select * is bad practice. Hibernate never uses this.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 21, 2004 10:22 am 
Regular
Regular

Joined: Fri Mar 26, 2004 11:45 am
Posts: 75
I think it makes sense to use select * and then use column names to retrieve values from the result set. Or, if Hibernate lists all the column names in the select clause, then column indices should be used to retrieve values from the results set. As far as I know Hibernate looks up values by column names, so using "select *" makes sense.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 28, 2004 12:09 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Hibernate use the index to retrieve column. Use of Driver metadata may be slow.

_________________
Emmanuel


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 9 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.