openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Pinaki Poddar <>
Subject Re: Need suggestion on Metamodel usage
Date Mon, 02 May 2011 16:16:39 GMT
To use canonical meta-model classes in developing Criteria query, follow
these steps:

  1. compile only the domain classes *only*, with -Aopenjpa.model=true
directives to activate OpenJPA-specialized Annotation Processor.
     The result is compilation of a domain class into X.class will
also generate both and X_.class.

  2. Now enhance X.class. The canonical meta-classes is not and need
not be enhanced (X_ is *not* a persistent type). 

  3. Now write the code for the class (say that uses Criteria API in
a type-safe manner using static fields of X_.class (generated in previous
step) instead of *any* string at all. If you are using an IDE for
development (who does not nowadays?) then your IDE will recognize these
canonical meta-classes such as X_ and with features like auto-completion
etc. will facilitate the dev process that uses Criteria Query.

  4. Now compile

For an example of these steps, check the simple Ant build file build.xml
supplied with OpenBooks -- a complete example available in OpenJPA source
code especially the target named "generate-canonical-model" [1].

> if i use enhanced classes then are there any performance issues? 
Yes. They make it run slightly faster.


View this message in context:
Sent from the OpenJPA Users mailing list archive at

View raw message