If you go on OpenJPA's documentation page
(http://openjpa.apache.org/documentation.html), you will notice that the
link you mention is the one provided for 'Latest (2.1.0-SNAPSHOT)' which is
trunk. There is no indication that this an official release yet.

If you go to documentation for release 2.0.0.
(http://openjpa.apache.org/builds/2.0.0/apache-openjpa-2.0.0/docs/manual/manual.html#d0e11088),
the -Aout=dir option is definitely mentioned. I am using this documentation,
because I want to develop on a stable release.

The other link you mention is general Javadoc.

I do read documentation ;-) I know that trick, that's how I found out about
the -Aout=dir option. 

Unfortunately, I don't see how the information provided in those links solve
the issue I raised.

Here is a simplified code example to replicate it:

package AnyPackage;

import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Id;
import javax.persistence.Persistence;
import javax.persistence.Table;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Root;

@Entity
@Table(name = "MY_TABLE")
public class MyAnnotatedClass implements Serializable {

    @Id
    private long TheID = Long.MIN_VALUE;

    @Column(name="NAME")
    private String Name = "";

    public long getTheID() { return TheID; }
    public void setTheID(long TheID) { this.TheID = TheID; }

    public String getName() { return Name; }
    public void setName(String Name) { this.Name = Name; }

    public static final EntityManagerFactory EMF =
Persistence.createEntityManagerFactory("openjpa");
    public static final EntityManager EM = EMF.createEntityManager();

    public static CriteriaQuery createCriteriaQuery(String inNameCriteria) {

        CriteriaBuilder queryBuilder = EM.getCriteriaBuilder();
        CriteriaQuery result = queryBuilder.createQuery();

        @SuppressWarnings("unchecked")
        Root<MyAnnotatedClass> mac = result.from(MyAnnotatedClass.class);

         mac.where(mac.get(MyAnnotatedClass_.Name).equal(inNameCriteria));

        return result;

    }

}

The above code won't compile with maven, even if openjpa.metamodel=true is
set. You can try it for yourself. The compiler complains that it can't find
MyAnnotatedClass_.

Even if you comment the 'mac' line, compile to generate the
MyAnnotatedClass_, uncomment and recompile, it does not work. 

I have tried the -s option with the following (and other values):

<compilerArgument>-Aopenjpa.metamodel=true
-s${basedir}/src/main/java</compilerArgument>

But it does not work.

If anyone has a solution...

Jérôme

P.S.: There is also an error in the 2.0.0 guide, which is still exists in
2.1.0 (see
http://openjpa.apache.org/builds/latest/docs/manual/manual.html#d0e11021).
The example mentions:

EntityManager em = ... ; 
CriteriaBuilder queryBuilder = em.getCriteriaBuilder();
CriteriaQuery qdef = queryBuilder.createCriteriaQuery();

But this method does not exist when importing
javax.persistence.criteria.CriteriaBuilder;
-- 
View this message in context: 
http://openjpa.208410.n2.nabble.com/Generation-of-Canonical-MetaModel-Classes-with-Maven-tp5424291p5432943.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Reply via email to