Hibernate:查询元数据 [英] Hibernate: Query Metadata
问题描述
我目前正在使用基于
a hibernate映射自动生成ExtJS表单的解决方案(我使用基于@Annotations的hibernate逆向工程)。
Hibernate有一个
getPropertiesInterator()
功能。这可以像这样访问
((LocalSessionFactoryBean)sessionFactory).getConfiguration()。getClassMapping(< Classname> .class.getName ())
其中列出了表的属性。我使用这些信息来生成ExtJS输入
varchar => input
text => textarea
etc。
我的问题是,如果有可能有另一种(也许更好)的方法来获取我的休眠配置中的信息?
/ p>
JS
我最后使用
ClassMetadata hibernateMetadata = session.getSessionFactory()。getClassMetadata(fullClassName);
要通过 [String]获取MetaData
ClassName或$ code> Class.class
有了这些信息,你可以这样做...
String [] propertyNames = hibernateMetadata.getPropertyNames();
Type [] propertyTypes = hibernateMetadata.getPropertyTypes();
稍后再分析此信息。
请参阅
了解更多信息。
Hibernate在他们的文档中甚至有一个例子...
http://docs.jboss.org/hibernate/orm/3.3/reference/en/html/objectstate.html#objectstate-metadata
I'm currently working on a solution to automatically generate ExtJS forms based on a hibernate mapping (I use hibernate reverse engineering for that based on @Annotations).
Hibernate has a
getPropertiesInterator()
funciton for that. Which is accessible like this
((LocalSessionFactoryBean)sessionFactory).getConfiguration().getClassMapping(<Classname>.class.getName())
Which lists the properties of the table. I use this information to generate ExtJS inputs out of it
varchar => input text => textarea etc.
My question is, if there is maybe another (maybe better) way to get this information out of my hibernate configuration?
Regards
JS
I ended up using
ClassMetadata hibernateMetadata = session.getSessionFactory().getClassMetadata(fullClassName);
To get the MetaData either by [String]
ClassName or by Class.class
With this information you can do something like this...
String[] propertyNames = hibernateMetadata.getPropertyNames();
Type[] propertyTypes = hibernateMetadata.getPropertyTypes();
And pars this information later on.
See
for more information.
Hibernate has even an example for this in their docs...
http://docs.jboss.org/hibernate/orm/3.3/reference/en/html/objectstate.html#objectstate-metadata
这篇关于Hibernate:查询元数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!