2011-02-23 52 views
1

有沒有辦法從我的應用程序代碼中獲取hibernate映射?例如, 對於下面的映射,我想從我的應用程序返回給定created_date的createdDate。從應用程序代碼獲取休眠映射

 
<property 
     name="createdDate" 
     type="java.lang.String" 
     column="created_date" 
     length="45" 
    /> 

回答

1

你也許可以通過使用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在那裏你可以得到你所需要的信息。