-->
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.  [ 8 posts ] 
Author Message
 Post subject: select x as something
PostPosted: Fri Jan 16, 2004 4:47 am 
Senior
Senior

Joined: Sun Jan 04, 2004 2:46 pm
Posts: 147
I've looked through the doco for a way to do this.

Code:
select cust.cust_id as CustomerId from customers cust


Is this possible in hibernate ( the aliasing of individual select items ) and I just missed the section that covers it?

If not is it something that might be added in the near future?

Cheers.

Myk.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 16, 2004 4:49 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
What the are you trying to do? In Hibernate you select class properties not column names or anything. You won't need the name you are trying to alias anywhere in the result or such.

So: No, it is not possible.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 16, 2004 10:16 am 
Senior
Senior

Joined: Sun Jan 04, 2004 2:46 pm
Posts: 147
The problem I'm having is the case where you select individual fields from several joined tables. The result sets that are returned are not self describing, as in you have to know the order in which fields are specified and access them by an array index which will break should a new field be inserted into the table anywhere but the end.

Our overall problem is we are trying to write a system that uses a C# frontend and Java server and for complex searches across several tables, pulling the hibernate objects across the network and reconstructing the object model is difficult so sometimes individual fields are sufficient and easier to manage.

Cheers.

Myk.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 16, 2004 10:18 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Okay, this may be a useful feature probably. How do you suggest Hibernate should return these "value names" ?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 16, 2004 10:20 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
No resultset is returned !
This is an array of Object. You're in object world.
Then map this array to a map having appropriate key

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 16, 2004 10:24 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Yes, thats true, but if you have somebody changing the query without changing the loading code, you will probably break the map generation process. Could be nice to define this in a query, but might not be worth the API bloat, and the confusion of people when HQL gets even more SQL like :)


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 16, 2004 10:52 am 
Senior
Senior

Joined: Sun Jan 04, 2004 2:46 pm
Posts: 147
All I could suggest is enhancing HQL to allow "as property_name" in select clauses and providing these column names as meta-data like getReturnTypes() of Query returns the types of each property/object in the select list. The alternative is to enhance either the objects that are returned or the list there are returned in to provide JDBC ResultSet functionality ( getxxx() ).

The second option isn't particular feasible or easy but the first would certainly fulfill my needs nicely as it binds names to result columns without having to worry about things breaking if table structures change. Plus it shouldn't break any current queries.

Thoughts?

Cheers.

Myk.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 16, 2004 10:53 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
You can add a feature request to JIRA and see what comes out.


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