• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Hibernate: property name from column name

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I need to find the name of an object property that is mapped to a database column. I attempted to use the Hibernate metadata but so far I have run into a wall. Can someone please provide an example of looking up the property name using the column name?

Thanks in advance,

Randy
 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi Randy ,
I am sorry to say this,but i think u need to be more clear with ur question. Could not really comprehend as to what exactly u are trying to ask.

Regards
Jyothi.
 
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I attempted to use the Hibernate metadata



I guess you are talking about the .hbm.xml file. In this file, you will find the database column name that you are searching for(if you are looking in the correct hbm file)
 
Randy Baker
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Jyothi Bhogadi:
...need to be more clear...Could not really comprehend as to what exactly u are trying to ask.


Jyothi

Thanks for responding and sorry that my question was not clear.

I am having to make my Hibernate persisted POJOs work with an older section of code. Within the code I have three variables containing the class of an object, the name of the database table to which the object is mapped, and the name of a column. I want to access the Hibernate metadata using that information to figure out the name of the property that is mapped to that column. If at all possible I do not want to have to parse the hbm.xml file.

Thanks!
[ February 07, 2006: Message edited by: Randy Baker ]
 
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
I think you are going to have to parse the hbm file. There is no way I know of other than that to get at the mapping info. org.hibernate.metadata.ClassMetaData just exposes the properties of a POJO, not any of the underlying mappings.
 
Jaikiran Pai
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
AbstractEntityPersister might be of some help. May be the getPropertyColumnNames method might be of your use. Not sure though
 
Let nothing stop you! Not even this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic