简体   繁体   English

使用JPA /休眠时,可以将orm.xml定义与注释混合吗?

[英]Is it possible to mix orm.xml definitions with annotations when using JPA/hibernate?

I'm working on an application whihc supports using several DB vendors, with the table definitions being different for each DB type. 我正在使用多个数据库供应商提供支持的应用程序,每种数据库类型的表定义都不同。 The trouble is that the column definitions are not what hibernate expects, and so my entities contain a lot of @Column(..columnDefintion="..."...) annotations. 问题在于列定义不是冬眠所期望的,因此我的实体包含很多@Column(.. columnDefintion =“ ...” ...)注释。

To further complicate the issue, there's no way to specify a columnDefinition per DB. 使问题更加复杂的是,无法为每个数据库指定columnDefinition。 So I tried moving just the columnDefinition bits to an orm.xml file, and I have a Maven profile that bundles the correct file. 因此,我尝试仅将columnDefinition位移动到orm.xml文件中,并且我拥有一个捆绑了正确文件的Maven配置文件。

JBoss 4.0.5/Hibernate 3.2.0GA fails to validate, and it seems it completely disregards the annotations given an xml file. JBoss 4.0.5 / Hibernate 3.2.0GA无法验证,似乎完全忽略了给定xml文件的注释。

Is there a way to make Hibernate "merge" the data from the xml with the annotations ? 有没有一种方法可以使Hibernate使用注释将xml中的数据“合并”?

JBoss 4.0.5/Hibernate 3.2.0GA fails to validate, and it seems it completely disregards the annotations given an xml file. JBoss 4.0.5 / Hibernate 3.2.0GA无法验证,似乎完全忽略了给定xml文件的注释。

Well, maybe you told him to do so (by specifying a metadata-complete attribute). 好吧,也许您告诉他这样做(通过指定一个metadata-complete属性)。 Maybe you should have shown your orm.xml (or one of them). 也许您应该已经显示了orm.xml (或其中之一)。

显然不是在使用jboss / hibernate im的版本中

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM