有没有办法从我的应用程序代码中获取 hibernate 映射? 例如,对于下面的映射,我想从应用程序中返回给定的created_date的createdDate。
<property name="createdDate" type="java.lang.String" column="created_date" length="45" />
最佳答案
您可能可以通过使用Configuration
来获取您需要的Property
来做到这一点,例如:-
Configuration configuration = new Configuration().configure("hibernate.cfg.xml");
Property property = configuration.getClassMapping("EntityName").getProperty("createdDate");
... // use the API from Property
这是the javadoc for Property您可以在其中获取所需的信息。
关于java - 从应用程序代码获取 hibernate 映射,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5085747/