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

Need column name in hibernate

 
Syed Saifuddin
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Everybody

I need to get all the column name in the string array using hibernate. is it posible or i have to use jdbc->resultsetmetadata for getting it.
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, you can do the JDBC way, but the point of Hibernate is to mask the database from Java. So that you deal with Java objects and not database stuff. So why would you need the column name? It is just mapped to an attribute, so you can just use the attribute and the attribute name.

Mark
 
Syed Saifuddin
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need the column entry in order. bcoz I have list of values in the same sequence of column
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Odd. Why do you have a list of values, rather than an object encapsulating the values?

That aside, if you really want the column names, you could do it via JDBC, as Mark suggests, or you could re-parse the mapping file and file out the column from the property name. Neither should be necessary if you are using Hibernate in a standard way though.
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Along Paul's thinking. The Configuration object will read it for you so you don't have to code the xml reading, and use the objects in the Configuration Object to get to the fields.

Mark
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic