Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hibernate 3.5 or 3.6 with no supporting to @Any annotation?

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!

like image 543
Lucas de Oliveira Avatar asked Nov 24 '10 18:11

Lucas de Oliveira


2 Answers

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)

like image 111
jpkrohling Avatar answered Oct 16 '22 05:10

jpkrohling


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

like image 32
dognose Avatar answered Oct 16 '22 04:10

dognose