Hibernate 3.5 或 3.6 不支持 @Any 注释?

发布于 2024-10-03 21:02:04 字数 1286 浏览 0 评论 0原文

我目前正在进行系统迁移(从带有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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

梦途 2024-10-10 21:02:04

您能否尝试将其添加到您的 Hibernate 属性中:

hibernate.ejb.metamodel.generation=disabled

这应该禁用元模型生成,避免您看到的异常。
(如评论中指出的那样,将属性值编辑为“禁用”)

Would you please try to add this to your Hibernate properties:

hibernate.ejb.metamodel.generation=disabled

This should disable the metamodel generation, avoiding the exception you are seeing.
(Edited property value to say 'disabled' as pointed out in comments)

維他命╮ 2024-10-10 21:02:04

或者,如果您不使用 hibernate.properties,请将 添加到 persistence.xml

Or, if you are not using hibernate.properties, add <property name="hibernate.ejb.metamodel.generation" value="disabled" /> to your persistence.xml

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文