openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Pinaki Poddar <ppod...@apache.org>
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 X.java into X.class will
also generate both X_.java and X_.class.

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


  3. Now write the code for the class (say Y.java 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 Y.java

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.


[1]
https://fisheye6.atlassian.com/browse/openjpa/trunk/openjpa-examples/openbooks/build.xml?hb=true

-----
Pinaki 
--
View this message in context: http://openjpa.208410.n2.nabble.com/Need-suggestion-on-Metamodel-usage-tp6317331p6324354.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Mime
View raw message