Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to extract column names from hibernate query

 
Tim McGuire
Ranch Hand
Posts: 820
IntelliJ IDE Tomcat Server VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is my code:


I'm looking for a way to get a collection from this query that contains the column names (fivePlus, fifteen, twentyfive, etc....)

Searching, I found some code that tries to parse the query string itself to extract column names, but it seems like there should be a way to extract the column names from the result set like there is in JDBC. Is this possible?
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't see how; you'll get the results back as a simple list, and the Query object itself won't give you the columns. Why not create an object to encapsulate the results?
 
Tim McGuire
Ranch Hand
Posts: 820
IntelliJ IDE Tomcat Server VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
David Newton wrote:I don't see how; you'll get the results back as a simple list, and the Query object itself won't give you the columns. Why not create an object to encapsulate the results?


You are saying a non-persisted object and populate it "by hand" with the results of the query?

as in


This I can do. What do you think would be the best way to store column names? In an array?
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hmm, no, I was saying to make an object that could be populated by the query directly.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic