7

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!

Lucas de Oliveira
  • 1,642
  • 11
  • 16
  • 1
    They are not supported only if you use JPA interface. With `SessionFactory` they work fine. – axtavt Nov 24 '10 at 19:18
  • that's strange...it works on hibernate 3.2 with jpa1. go figure. I'll stick with 3.2 for now =/ – Lucas de Oliveira Nov 24 '10 at 19:35
  • 2
    That's pretty clear. JPA2 includes metamodel support. Since it's not clear how to represent `@Any` attributes in a metamodel, they have to prohibit such attributes (it can be deduced from the stacktrace). – axtavt Nov 24 '10 at 19:43
  • Do you know what would be the relative annotation to @Any in JPA2? – Lucas de Oliveira Nov 24 '10 at 20:16

2 Answers2

5

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)

Valters Vingolds
  • 1,271
  • 10
  • 16
jpkroehling
  • 13,881
  • 1
  • 37
  • 39
1

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

dognose
  • 20,360
  • 9
  • 61
  • 107