【发布时间】:2011-08-12 11:47:35
【问题描述】:
有没有办法获取关于我的 Hibernate Annotations 的元数据?
我需要关于关联的信息,看看它们是否可为空。
现在只能查询ClassMetadata
http://docs.jboss.org/hibernate/core/3.5/javadocs/org/hibernate/metadata/ClassMetadata.html
我可以在哪里运行属性并检查它是否是一个
EntityType
http://docs.jboss.org/hibernate/core/3.5/javadocs/org/hibernate/type/EntityType.html
或CollectionType
http://docs.jboss.org/hibernate/core/3.5/javadocs/org/hibernate/type/CollectionType.html
EntityType 显然有一个isNullable 函数但没有CollectionType
所以我想到了使用Annotation信息
@GenericGenerator(name = "generator", strategy = "foreign", parameters = @Parameter(name = "property", value = "seizureI18n"))
@Id
@GeneratedValue(generator = "generator")
@Column(name = "id", unique = true, nullable = false)
public Integer getId() {
return this.id;
}
这是否可能或另一种方式来实现我想要的。
问候
JS
【问题讨论】:
标签: java hibernate reflection annotations