Pergunta

Using sbt, what should I do to execute annotation processor org.eclipse.persistence.internal.jpa.modelgen.CanonicalModelProcessor provided by EclipseLink in order to generate the metamodel from my entity classes?

Foi útil?

Solução

For the impatient

  1. Clone project ssdemojpa

    $ git clone http://github.com/frgomes/ssdemojpa

  2. Enter the commands below from the SBT console:

zap
reload
metamodel
compile
test

Detailed Description

Project ssdemojpa provides a demo about how PlayFramework can be integrated with SecureSocial (for OpenID/OAuth/OAuth2 authentication) and EclipseLink (as a JPA provider). The demo application also provides a very simple integration with Twitter4J in order to retrieve trends from Twitter.

SBT script: https://github.com/frgomes/ssdemojpa/blob/master/project/Build.scala

In the SBT build script referenced above the trait Metamodel is responsible for defining task metamodel which processes the JPA entity classes and generates the metamodel in the same directory where your entity classes are located.

Notice that the submodule models contains annotated JPA entity classes and must be compiled with Java8, since Java8 syntax is employed in DAO classes (but not in entity classes).

Notice that the annotation processor does not recognize features introduced by Java7 and Java8, but you can compile your code using Java7 or Java8 anyway, provided that you do not employ Java7/Java8 syntax in your entity classes. You can employ Java7/Java8 syntax in other classes. Again: ssdemojpa requires Java8.

In case you compile your code with Java7 or Java8, the annotation processor will emit a warning complaining about that but it will generate the associated metaclasses anyway, since your entity classes necessarily obey with Java6 syntax. The warning message is irrelevant in this case and everything should work just fine, provided that you've defined your entity classes properly.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top