views:

630

answers:

2

How can I access the Hibernate mapping of my model to find out the column name of a property?

The column name is not specified in the mapping so Hibernate generates it automatically - I would like to create a native SQL statement including this column name.

A: 

You have to have access to the Hibernate Configuration object.

Jherico
that should be possible in a spring environment ...
Thomas Einwaller
+1  A: 

Thanks to Jherico I found out how to do that:

((Column) sessionFactoryBean.getConfiguration().getClassMapping(Person.class.getName())
        .getProperty("myProperty").getColumnIterator().next()).getName();
Thomas Einwaller