获取使用Hibernate映射的属性的列名称 [英] Get column name of property mapped with Hibernate
本文介绍了获取使用Hibernate映射的属性的列名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何访问我的模型的Hibernate映射以查找属性的列名称?
$ b 在映射中未指定列名,所以Hibernate会自动生成它 - 我想创建一个包含此列名的本地SQL语句。
解决方案
感谢Jherico,我发现了如何做到这一点:
((Column)sessionFactoryBean.getConfiguration()。getClassMapping(Person.class.getName())
.getProperty(myProperty)。getColumnIterator()。next())。getName();
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.
解决方案
Thanks to Jherico I found out how to do that:
((Column) sessionFactoryBean.getConfiguration().getClassMapping(Person.class.getName())
.getProperty("myProperty").getColumnIterator().next()).getName();
这篇关于获取使用Hibernate映射的属性的列名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文