Hibernate 3.5 或 3.6 不支持 @Any 注释?
我目前正在进行系统迁移(从带有JPA1的hibernate 3.2.2.GA到带有JPA2的hibernate 3.6)。迁移本身非常简单,没有重大更新要做(事实上,我认为没有 我面临的
问题是 hibernate 在运行时抛出异常,抱怨 @Any 注释。
Caused by: java.lang.UnsupportedOperationException: any not supported yet
at org.hibernate.ejb.metamodel.AttributeFactory.determineAttributeMetadata(AttributeFactory.java:452)
at org.hibernate.ejb.metamodel.AttributeFactory.buildAttribute(AttributeFactory.java:93)
at org.hibernate.ejb.metamodel.MetadataContext.wrapUp(MetadataContext.java:183)
at org.hibernate.ejb.metamodel.MetamodelImpl.buildMetamodel(MetamodelImpl.java:66)
at org.hibernate.ejb.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:84)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:902)
at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:74)
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:225)
因此,这意味着 hibernate 不再支持 @Any 或 @ManyToAny。很奇怪,因为文档(从 3.3 到 3.6)提到了如何使用 @Any 注释,而且据我所知,没有 hibernate 版本贬低此注释。
我检查了 hibernate 3.5 源代码,并且 @Any 注释检查也在那里,所以它也存在。抛出同样的异常,
你们有解决这个问题的方法吗
?
I'm currently working on a system migration (from hibernate 3.2.2.GA with JPA1 to hibernate 3.6 with JPA2. The migration itself is very simple, there are no major updates to do (in fact, I don't think there is any at all).
The problem I'm facing is that hibernate throws an exception at runtime, complaining about the @Any annotations. The stacktrace is the following:
Caused by: java.lang.UnsupportedOperationException: any not supported yet
at org.hibernate.ejb.metamodel.AttributeFactory.determineAttributeMetadata(AttributeFactory.java:452)
at org.hibernate.ejb.metamodel.AttributeFactory.buildAttribute(AttributeFactory.java:93)
at org.hibernate.ejb.metamodel.MetadataContext.wrapUp(MetadataContext.java:183)
at org.hibernate.ejb.metamodel.MetamodelImpl.buildMetamodel(MetamodelImpl.java:66)
at org.hibernate.ejb.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:84)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:902)
at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:74)
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:225)
So it means that @Any or @ManyToAny are no longer supported by hibernate. This is weird because the documentation (from 3.3 to 3.6) mentions how to use the @Any annotation and AFAIK there is no hibernate version that depreciates this annotation.
I checked hibernate 3.5 source code and the @Any annotation checking is there also, so it also throws the same exception.
Do you guys have any workaround for this issue?
thanks a lot!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您能否尝试将其添加到您的 Hibernate 属性中:
这应该禁用元模型生成,避免您看到的异常。
(如评论中指出的那样,将属性值编辑为“禁用”)
Would you please try to add this to your Hibernate properties:
This should disable the metamodel generation, avoiding the exception you are seeing.
(Edited property value to say 'disabled' as pointed out in comments)
或者,如果您不使用 hibernate.properties,请将
添加到 persistence.xmlOr, if you are not using hibernate.properties, add
<property name="hibernate.ejb.metamodel.generation" value="disabled" />
to your persistence.xml