• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibernate: property name from column name

 
Randy Baker
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • 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
 
Jyothi Bhogadi
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • 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.
 
Jaikiran Pai
Marshal
Pie
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • 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
  • 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 ]
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • 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
Marshal
Pie
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
AbstractEntityPersister might be of some help. May be the getPropertyColumnNames method might be of your use. Not sure though
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic