Skip non-JPA features populating JPA "static metamodel"

Description

I am upgrading from Hibernate 3.2.x to 3.5.5 and getting UnsupportedOperationExceptions thrown when Hibernate is trying to create the metamodel. This is due to the dependency of my application upon jBPM 3.x, which uses "any" mappings for some of its classes.

The exception occurs in org.hibernate.ejb.metamodel.AttributeFactory.determineAttributeMetadata(...)

It is due to the logic in AttributeFactory at line 451:

The "Big Hammer" approach of globally disabling the creation of the metamodel with the property setting:

is not feasible: other components in my application depend upon the criteria search api, which need a generated meatamodel. Splitting the single application persistence unit into two parts ( one for the jBPM persisted classes with metamodel disabled and all other classes with metamodel enabled) is not feasible either. The split persistence unit approach would also split transaction boundaries of operations that are desired to be in a single transaction.

Hibernate should support "any" mappings in the metamodel. The @Any annotation is supported in Hibernate Annotation 3.5.5.

If Hibernate can not support "any" mappings then maybe it could:

  • Allow the exclusion of persistent classes by package in the metamodel. I tried this successfully by changing the following code in org.hibernate.ejb.EntityManagerFactoryImpl constructor:

  • Exclude persistent classes having "any" mappings from the metamodel generation.

Environment

Hibernate entity manager 3.5.5, PostgreSQL 8.4

Activity

Show:
Minas Manthos
January 26, 2012, 12:51 PM

IMO this issue is a Bug because you're not able to use hibernate mainly in JPA2 context (and in exceptional cases using hibernate native things link @Any). Of course, @Any is not supported by JPA2 (and you cannot query it) but this should not prevent using JPA Metamodel and CriteriaBuilder in all other cases. Currently you have only the option to disable metamodel building completely, but this means also that you cannot use JPA2 CriteriaBuilder anymore.

I suggest to extend property "hibernate.ejb.metamodel.generation" with followed value:

ignoreUnsupported: create metamodel, but ignore unsupported/unknown annotations

Pull request: https://github.com/hibernate/hibernate-orm/pull/257

option "disabled" and option not set remains unchanged...

Assignee

Steve Ebersole

Reporter

Robert Brady

Fix versions

Labels

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

Priority

Major
Configure