JPA 2.0 support - metamodel generation?

I was wondering if IDEA 9 support for JPA 2.0 includes generation of entity metamodel classes as discussed here [1] here [2] and here [3]. Doing a search in Help for metamodel did not yield any results. Eclipselink support in particular would be useful since that is what Glassfishv3 bundles with itself by default. Should I file an RFE? Thanks.

-Noah

[1] - http://blogs.sun.com/ldemichiel/entry/java_persistence_2_0_proposed#comments

[2] - http://weblogs.java.net/blog/lancea/archive/2009/12/15/generating-jpa-20-static-metamodel-classes-using-eclipselink-20-and-n

[3] - http://wiki.eclipse.org/UserGuide/JPA/Using_the_Canonical_Model_Generator_(ELUG)

0
7 comments

Please, follow
http://blogs.jetbrains.com/idea/2009/11/userfriendly-annotation-processing-support-jpa-20-metamodel/

On 02.03.2010 6:11, nbw-intellijnet wrote:

I was wondering if IDEA 9 support for JPA 2.0 includes generation of entity metamodel classes as discussed here and here . Doing a search in Help for metamodel did not yield any results. Thanks.

>

-Noah

>

- http://blogs.sun.com/ldemichiel/entry/java_persistence_2_0_proposed#comments

>

- http://weblogs.java.net/blog/lancea/archive/2009/12/15/generating-jpa-20-static-metamodel-classes-using-eclipselink-20-and-n

>

---
Original message URL: http://www.jetbrains.net/devnet/message/5257678#5257678



--
Best regards,
   Maxim Mossienko
IntelliJ Labs / JetBrains Inc.
http://www.intellij.com
"Develop with pleasure!"

0

Hi Maxim,

Thanks for the tip. I checked out the blog and tried to set things up for EclipseLink annotations processing but wasn't too successful. Here are my results:

I tried setting things up for Eclipselink but the Build -> Process Annotations menu remains grayed out after completing these steps.

When I rebuilt my project it deleted my src directory since I had tried to point the generated classes folder to my src folder so that the generated classes would be side by side with the entity classes so I can check them in and include them in my source path.  There should definitely be a warning that it deletes that directory!   I'm not sure what IDEA is setting the processors working directory to but in the case of Eclipselink I have one processor run option set like so:

eclipselink.persistencexml=web/META-INF/persistence.xml but when I rebuild the project I get an error saying:

"Unable to load persistence.xml G:\sandbox\trunk\myproject\build\production\myproject\web\META-INF\persistence.xml"

I tried changing the value if the option to be a relative path from the build\production\myproject folder back to my persistence.xml file like so:

eclipselink.persistencexml=../../../web/META-INF/persistence.xml

but that gave me the following error:

java.lang.IllegalArguementException: relativeName is invalid

Has anyone set this up with Eclipselink? BTW, I can generate them by hand on the command link with "javac -processor org.eclipse.persistence.internal.jpa.modelgen.CanonicalModelProcessor ..." so I know I have my options and classpath information correct and I am just not understanding the magic to make IDEA happy.

Thanks,

-Noah

0

Hi,

I have the exact same problem. EclipseLink expects the persistence.xml file to be in the classpath (under the target directory) but not in the source path. We then need to tell EclipseLink to look for the persistence.xml file under a different location (src/main/resources/META-INF if you follow a Maven structure). So in the Annotation Processors menu in the Processor Run Options we need to set the eclipselink.persistencexml property. But it doesn't work. I've tried the full path (c:\myproject\src\main...) a relative path (..\..\src\main...).... nothing seems to work.

Any idea ?
Thanks,
Antonio

0

Hello Antonio,

eclipselink.persistencexml=META-INF/persistence.xml

works fine if the file is actually under <src-root>/META-INF.

In your case src/main/resources should be marked as source root.
Then on annotation processing step persistence.xml will be first copied
to the output (build/META-INF/persistence.xml)
where that nasty EclipseLink processor is expects it.

This should work unless you have something extra in your setup like you
do not copy xml resources to output on build, etc.

Regards,
Gregory Shrago


On 27.05.2010 20:51, Antonio Goncalves wrote:

Hi,

>

I have the exact same problem. EclipseLink expects the persistence.xml file to be in the classpath (under the target
directory) but not in the source path. We then need to tell EclipseLink to look for the persistence.xml file under a
different location (src/main/resources/META-INF if you follow a Maven structure). So in the Annotation Processors menu in the
Processor Run Options we need to set the eclipselink.persistencexml property. But it doesn't work. I've tried the full path
(c:\myproject\src\main...) a relative path (..\..\src\main...).... nothing seems to work.

>

Any idea ? Thanks, Antonio

>

--- Original message URL: http://www.jetbrains.net/devnet/message/5264185#5264185


0

Guest wrote:

Hello Antonio,

eclipselink.persistencexml=META-INF/persistence.xml

works fine if the file is actually under <src-root>/META-INF.

In your case src/main/resources should be marked as source root.
Then on annotation processing step persistence.xml will be first copied
to the output (build/META-INF/persistence.xml)
where that nasty EclipseLink processor is expects it.

This should work unless you have something extra in your setup like you
do not copy xml resources to output on build, etc.

Regards,
Gregory Shrago



Hi Gregory,

I followed your tip and I added src/main/resources to my list of source roots. Then I modified my Annotation Processor settings so that I have eclipselink.persistencexml=META-INF/persistence.xml

I also set my Generated Sources Directory Name to generated

Now when I rebuild my project the metamodel classes are generated under my generated folder, however, the classes that depended on them failed to compile as they could not locate them.

So after that I added the generated folder to my list of source roots. Now I am seeing a compile errors from the metamodel classes when I try to build. The errors indicate that the metamodel generated classes can't locate classes that are present in the main source root. I don't see why they can't as these classes are are in the main source root and build fine. It seems like I have a circular build dependency problem.

I think I must still be missing something with regards to the project configuration, source roots etc.

Any thoughts?

Thanks,

-Noah

0

Hello,

Here's the sample project that uses EclipseLink processor.
http://confluence.jetbrains.net/download/attachments/19989371/JpaEclipseLinkProcessorSample.zip

Gregory Shrago

0

Please check whether the sample project works for you.
http://confluence.jetbrains.net/download/attachments/19989371/JpaEclipseLinkProcessorSample.zip


On 03.06.2010 6:16, nbw-intellijnet wrote:

Hi Gregory,

>

I followed your tip and I added src/main/resources to my list of source roots. Then I modified my Annotation Processor settings so that I have eclipselink.persistencexml=META-INF/persistence.xml
I also set my Generated Sources Directory Name to generated
Now when I rebuild my project the metamodel classes are generated under my generated folder, however, the classes that depended on them failed to compile as they could not locate them.
So after that I added the generated folder to my list of source roots. Now I am seeing a compile errors from the metamodel classes when I try to build. The errors indicate that the metamodel generated classes can't locate classes that are present in the main source root. I don't see why they can't as these classes are are in the main source root and build fine. It seems like I have a circular build dependency problem.
I think I must still be missing something with regards to the project configuration, source roots etc.

>

Any thoughts?

>

Thanks,

>

-Noah

>

---
Original message URL: http://www.jetbrains.net/devnet/message/5264651#5264651


0

Please sign in to leave a comment.