문제

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!

도움이 되었습니까?

해결책

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)

다른 팁

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top