Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] How to use the criteria api metamodel in a java se project?

Thank you for the answer.

I still have compilation problems with maven.
Please checkout my project from
svn checkout https://memorizeasy.googlecode.com/svn/trunk/MemoPlatform/persistence/

The metaclasses get generated, but when I choose to build it the
following error trace is output:

NetBeans: Executing 'mvn -Dnetbeans.execution=true install -e'
NetBeans:      JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Home
+ Error stacktraces are turned on.
Scanning for projects...
[WARNING]
        Profile with id: 'Profile' has not been activated.

------------------------------------------------------------------------
Building MemoPlatform - Persistence NetBeans Module
   task-segment: [install]
------------------------------------------------------------------------
[processor:process]
Source directory:
/Users/simpatico/ws/MemoPlatform/persistence/src/main/generated added
No processors specified. Using default discovery mechanism.
javac option: -cp
javac option: /Users/simpatico/ws/MemoPlatform/persistence/src/main/resources:/Users/simpatico/ws/MemoPlatform/persistence/target/classes:/Users/simpatico/.m2/repository/org/eclipse/persistence/eclipselink/2.0.2/eclipselink-2.0.2.jar:/Users/simpatico/.m2/repository/org/eclipse/persistence/javax.persistence/2.0.2/javax.persistence-2.0.2.jar:/Users/simpatico/.m2/repository/org/netbeans/api/org-openide-actions/RELEASE691/org-openide-actions-RELEASE691.jar:/Users/simpatico/.m2/repository/org/netbeans/api/org-openide-awt/RELEASE691/org-openide-awt-RELEASE691.jar:/Users/simpatico/.m2/repository/org/netbeans/api/org-openide-util/RELEASE691/org-openide-util-RELEASE691.jar:/Users/simpatico/.m2/repository/org/netbeans/api/org-openide-util-lookup/RELEASE691/org-openide-util-lookup-RELEASE691.jar:/Users/simpatico/.m2/repository/org/netbeans/api/org-openide-dialogs/RELEASE691/org-openide-dialogs-RELEASE691.jar:/Users/simpatico/.m2/repository/org/netbeans/api/org-netbeans-api-progress/RELEASE691/org-netbeans-api-progress-RELEASE691.jar:/Users/simpatico/.m2/repository/org/netbeans/api/org-openide-explorer/RELEASE691/org-openide-explorer-RELEASE691.jar:/Users/simpatico/.m2/repository/org/netbeans/api/org-netbeans-swing-outline/RELEASE691/org-netbeans-swing-outline-RELEASE691.jar:/Users/simpatico/.m2/repository/org/netbeans/api/org-netbeans-swing-tabcontrol/RELEASE691/org-netbeans-swing-tabcontrol-RELEASE691.jar:/Users/simpatico/.m2/repository/org/netbeans/api/org-openide-windows/RELEASE691/org-openide-windows-RELEASE691.jar:/Users/simpatico/.m2/repository/org/netbeans/api/org-openide-nodes/RELEASE691/org-openide-nodes-RELEASE691.jar:/Users/simpatico/.m2/repository/org/netbeans/api/org-openide-text/RELEASE691/org-openide-text-RELEASE691.jar:/Users/simpatico/.m2/repository/org/netbeans/api/org-netbeans-modules-editor-mimelookup/RELEASE691/org-netbeans-modules-editor-mimelookup-RELEASE691.jar:/Users/simpatico/.m2/repository/org/netbeans/api/org-openide-filesystems/RELEASE691/org-openide-filesystems-RELEASE691.jar:/Users/simpatico/.m2/repository/org/netbeans/api/org-openide-modules/RELEASE691/org-openide-modules-RELEASE691.jar
javac option: -proc:only
javac option: -d
javac option: /Users/simpatico/ws/MemoPlatform/persistence/target/classes
javac option: -s
javac option: /Users/simpatico/ws/MemoPlatform/persistence/src/main/generated
[resources:resources]
Using 'UTF-8' encoding to copy filtered resources.
Copying 1 resource
[compiler:compile]
Compiling 4 source files to
/Users/simpatico/ws/MemoPlatform/persistence/target/classes
-------------------------------------------------------------
[ERROR]COMPILATION ERROR :
-------------------------------------------------------------
[ERROR]com/mysimpatico/memoplatform/persistence/Database.java:[127,43]
cannot find symbol
symbol  : variable lastPublishedDate
location: interface
javax.persistence.metamodel.EntityType<com.mysimpatico.memoplatform.persistence.entities.Meaning>

[ERROR]com/mysimpatico/memoplatform/persistence/Database.java:[128,35]
cannot find symbol
symbol  : variable objId
location: interface
javax.persistence.metamodel.EntityType<com.mysimpatico.memoplatform.persistence.entities.Meaning>

2 errors
-------------------------------------------------------------
------------------------------------------------------------------------
[ERROR]BUILD FAILURE
------------------------------------------------------------------------
Compilation failure

com/mysimpatico/memoplatform/persistence/Database.java:[127,43] cannot
find symbol
symbol  : variable lastPublishedDate
location: interface
javax.persistence.metamodel.EntityType<com.mysimpatico.memoplatform.persistence.entities.Meaning>

com/mysimpatico/memoplatform/persistence/Database.java:[128,35] cannot
find symbol
symbol  : variable objId
location: interface
javax.persistence.metamodel.EntityType<com.mysimpatico.memoplatform.persistence.entities.Meaning>


------------------------------------------------------------------------
Trace
org.apache.maven.BuildFailureException: Compilation failure
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:699)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:540)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:519)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:371)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:332)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:181)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:356)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:137)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
        at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:41)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
        at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
        at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
        at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: org.apache.maven.plugin.CompilationFailureException:
Compilation failure
        at org.apache.maven.plugin.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:656)
        at org.apache.maven.plugin.CompilerMojo.execute(CompilerMojo.java:128)
        at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:483)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:678)
        ... 17 more
------------------------------------------------------------------------
Total time: 4 seconds
Finished at: Wed Aug 11 19:37:05 AST 2010
Final Memory: 25M/81M
------------------------------------------------------------------------


2010/8/11, Michael O'Brien <michael.obrien@xxxxxxxxxx>:
> Gabriele,
>     Yes, the Criteria and Metamodel API's are part of JPA 2.0 which is
> part of JEE6.  JPA 1.0/2.0 has always supported SE persistence via the
> javax.persistence specification package import.
>     Your code on the stackoverflow post looks fine, you do not require
> canonical generated classes as your EntityType<Meaning> dynamic
> metamodel Type class is ok to use.
>
>     A Java SE test model is in SVN below.
> http://fisheye2.atlassian.com/browse/eclipselink/trunk/jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/models/jpa/metamodel
>
>     The Java SE metamodel (dynamic in-memory non-canonical) test cases
> are below.
> http://fisheye2.atlassian.com/browse/eclipselink/trunk/jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/models/jpa/metamodel
>
>     For persistence.xml you do not need to use the JPA 2.0 schema unless
> you require use of new elements/attributes introduced in 2.0 - there are
> none for Criteria/Metamodel except for canonical generation (if you
> require it).  The "em.getMetamodel()" call does not require static
> generated classes - it will generate them in-memory as your Meaning_
> variable.
> http://wiki.eclipse.org/UserGuide/JPA/Using_the_Canonical_Model_Generator_(ELUG)#EclipseLink_custom_processor_options
>
>     Either of these headers will work in persistence.xml - use the 2.0
> one if you use one of the 5 canonical metamodel properties introduced in 2.0
>
> <!-- persistence version="2.0"
> xmlns="http://java.sun.com/xml/ns/persistence";
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
> xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
> http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"-->
> <persistence version="1.0"
> xmlns="http://java.sun.com/xml/ns/persistence";
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
> xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
> http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd";>
>
>     For usage, there are 3 ways to use the Metamodel API detailed below
> (Static - via canonical modelgen generated "_" classes, dynamic in
> memory typesafe and dynamic in memory non-typesafe (using String get
> methods)
> http://wiki.eclipse.org/EclipseLink/Development/JPA_2.0/metamodel_api#API_Usage
>
>     I do not see anything JPA 2.0 related in your Entity.
>     If you are seeing compile-time or run-time errors running this query
> - you may post the stacktrace and logs if you would like.
>     thank you
>     /michael
>
>
> Gabriele Kahlout wrote:
>> http://stackoverflow.com/questions/3458742/why-the-compiler-doesnt-recognize-the-metamodel-attributes
>>
>
> _______________________________________________
> eclipselink-users mailing list
> eclipselink-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/eclipselink-users
>


-- 
Regards,
K. Gabriele

--- unchanged since 25/1/10 ---
P.S. Unless a notification (LON), please reply either with an answer
OR with " ACK" appended to this subject within 48 hours. Otherwise, I
might resend.
In(LON, this) ∨ In(48h, TimeNow) ∨ ∃x. In(x, MyInbox) ∧ IsAnswerTo(x,
this) ∨ (In(subject(this), subject(x)) ∧ In(ACK, subject(x)) ∧
¬IsAnswerTo(x,this)) ⇒ ¬IResend(this).

Also note that correspondence may be received only from specified a
priori senders, or if the subject of this email ends with a code, eg.
-LICHT01X, then also from senders whose reply contains it.
∀x. In(x, MyInbox) ⇒ In(senderAddress(x), MySafeSenderList) ∨ (∃y.
In(y, subject(this) ) ∧ In(y,x) ∧ isCodeLike(y, -LICHT01X) ).


Back to the top