• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Getting property / column names from mapping file

 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
1. I need to get the hibernate column name corresponding to a database column name that I have in my application. Is there a way to query the mapping file for that class / table and retrieve hibernate property name for a given column name ?
2. Is there also a way to get all the columns for a particular class / table in my application at runtime ?

Please can anyone tell me which API in hibernate would let me do this ?

Harsha
 
Harsha Pherwani
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I got the API by which we can get the properties and with that retrieve the name of the column it is associated with.
By getting the Mapping class from the configuration object and then getting the property fform that.
I dont think there is a way to get the name of the Hibernate property if the name of the column is know.
If anyone knows otherwise, please let me know.

Thanks.
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, mapping files are just XML so you could just parse them and use XPath to get the field name for a particular property. Not really sure why you would want to do this though.
 
Harsha Pherwani
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Initally when we designed the system, when we hadnt thought of hibernate yet; a requirement said that we had to assign rules to the columns of a table. But now it would have to be the fields of the hibernate file instead. So I was wondering if I could get the column names from hibernate and still maintain the same requirement.

Thanks.
Harsha
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic