In the spirit of type safety associated with the CriteriaQuery JPA 2.0 also has an API to support Metamodel representation of entities.
Is anyone aware of a fully functional implementation of this API (to generate the Metamodel as opposed to creating the metamodel classes manually)? It would be awesome if someone also knows the steps for setting this up in Eclipse (I assume it's as simple as setting up an annotation processor, but you never know).
EDIT: Just stumbled across Hibernate JPA 2 Metamodel Generator . But the issue remains since I can't find any download links for the jar.
EDIT 2: Awhile has passed since I asked this question, but I thought I'd come back and add a link to the Hibernate JPA Model Generator project on SourceForge
The JPA Metamodel API provides the ability to examine the persistent object model and retrieve details on managed classes and persistent fields and properties, similarly to the ability that Java reflection provides for general Java types.
The Metamodel API is used to create a metamodel of the managed entities in a particular persistence unit. For each entity class in a particular package, a metamodel class is created with a trailing underscore and with attributes that correspond to the persistent fields or properties of the entity class.
Hibernate Metamodel Generator is an annotation processor automating the generation of the static metamodel classes needed for typesafe Criteria queries as defined by JPA 2.
Interface SingularAttribute<X,T> Superinterfaces: Attribute<X,T> , Bindable<T> Instances of the type SingularAttribute represents persistent single-valued properties or fields. Class<T> getBindableJavaType() Return the Java type of the represented object.
It would be awesome if someone also knows the steps for setting this up in Eclipse (I assume it's as simple as setting up an annotation processor, but you never know)
Yes it is. Here are the implementations and instructions for the various JPA 2.0 implementations:
org.eclipse.persistence.internal.jpa.modelgen.CanonicalModelProcessor
org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor
org.apache.openjpa.persistence.meta.AnnotationProcessor6
org.datanucleus.jpa.JPACriteriaProcessor
The latest Hibernate implementation is available at:
An older Hibernate implementation is at:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With