Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Create Canonical Metamodel without using any JPA/EclipseLink Annotations
Create Canonical Metamodel without using any JPA/EclipseLink Annotations [message #673419] Mon, 23 May 2011 15:15 Go to next message
mgira  is currently offline mgira Friend
Messages: 6
Registered: May 2011
Junior Member
Hi all,

i was looking for a way to create a JPA 2 Canonical Metamodel from my entites with EclipseLink.

Since i'm not using any JPA/EclipseLink Annotations at all but only orm.xml and eclipselink-orm.xml, the CanonicalModelProcessor doesn't even get to start, or maybe it's me doing something wrong.

Is there a way to create a Canonical Metamodel from my Entity Mappings without having to use Annotations?
If so, what am i missing?

I'm using Maven btw.

Thanks in advance

[Updated on: Mon, 23 May 2011 15:18]

Report message to a moderator

Re: Create Canonical Metamodel without using any JPA/EclipseLink Annotations [message #673740 is a reply to message #673419] Tue, 24 May 2011 15:27 Go to previous messageGo to next message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

The metamodel generator should work with XML or annotations. What error do you get?

How are you executing the generator, is your orm.xml file listed in your persistence.xml and on the classpath?


James : Wiki : Book : Blog : Twitter
Re: Create Canonical Metamodel without using any JPA/EclipseLink Annotations [message #673946 is a reply to message #673740] Wed, 25 May 2011 08:56 Go to previous messageGo to next message
mgira  is currently offline mgira Friend
Messages: 6
Registered: May 2011
Junior Member
Hi James, thanks for your reply.

James wrote on Tue, 24 May 2011 11:27
The metamodel generator should work with XML or annotations.

After a bit of research, i think that it will not work unless i use JPA Annotations, so, if there is not one single JPA Annotation used, the CanonicalModelProcessor will not be triggered at all.
You are probably referering to the documentation, i've read it up&down,IMHO they missed out to put in a small bit of important information: No Annotations, no canonical metamodel

Quote:
What error do you get?

No error, but no "action" either.

James wrote on Tue, 24 May 2011 11:27

How are you executing the generator, is your orm.xml file listed in your persistence.xml and on the classpath?

I'm using the Maven Plugin maven-processor-plugin from org.bsc.maven.

The log shows that the Processor is not invoked at all (since it relies on Annotations):
[INFO] Adding compiler arg: -Aeclipselink.persistencexml=src/main/resources/META-INF/persistence.xml
[INFO] javac option: -cp
[INFO] javac option: C:\sources\workspace_3.6.1_JEE\myproject-parent\myproject-domain\src\main\resources;C:\sources\workspace_3.6.1_JEE\myproject-parent\myproject-domain\target\classes;C:\Users\USERNAME\.m2\repository\org\slf4j\slf4j-api\1.5.8\slf4j-api-1.5.8.jar;C:\Users\USERNAME\.m2\repository\org\slf4j\slf4j-log4j12\1.5.8\slf4j-log4j12-1.5.8.jar;C:\Users\USERNAME\.m2\repository\log4j\log4j\1.2.14\log4j-1.2.14.jar;C:\Users\USERNAME\.m2\repository\com\google\inject\guice\3.0\guice-3.0.jar;C:\Users\USERNAME\.m2\repository\javax\inject\javax.inject\1\javax.inject-1.jar;C:\Users\USERNAME\.m2\repository\aopalliance\aopalliance\1.0\aopalliance-1.0.jar;C:\Users\USERNAME\.m2\repository\com\google\inject\extensions\guice-persist\3.0\guice-persist-3.0.jar;C:\Users\USERNAME\.m2\repository\org\eclipse\persistence\javax.persistence\2.0.3\javax.persistence-2.0.3.jar;C:\Users\USERNAME\.m2\repository\org\eclipse\persistence\eclipselink\2.2.0\eclipselink-2.2.0.jar
[INFO] javac option: -proc:only
[INFO] javac option: -Aeclipselink.persistencexml=src/main/resources/META-INF/persistence.xml
[INFO] javac option: -processor
[INFO] javac option: org.eclipse.persistence.internal.jpa.modelgen.CanonicalModelProcessor
[INFO] javac option: -d
[INFO] javac option: C:\sources\workspace_3.6.1_JEE\myproject-parent\myproject-domain\target\classes
[INFO] javac option: -s
[INFO] javac option: C:\sources\workspace_3.6.1_JEE\myproject-parent\myproject-domain\target\generated-sources\apt
[INFO] diagnostic warning: The following options were not recognized by any processor: '[eclipselink.persistencexml]'

If i start using JPA Annotations (like @Entity, @Embeddable), the Processor gets triggered and does create a canonical metamodel, and apperantly it does take the orm.xml into account also.

However, i have to avoid annotations in this project (proof of concept, that is also supposed to show differences between JPA and JDO), so this is not an option, or at least to me, the cannonical metamodel is not worth putting in JPA annotations.

org.eclipse.persistence.internal.jpa.modelgen.CanonicalModelProcessor extends
javax.annotation.processing.AbstractProcessor, so far it looks to me, the only way to use it, is using annotations.
Btw., Hibernate, OpenJPA and DataNuclues for JPA also use an Annotation Processor for creating the canonical metamodel, the JPA 2 spec. does not specifiy that the JPA implementor needs to supply a tool for creating the metamodel at all.

What puzzles me is that i was told that projects like Teneo and others do create a canonical metamodel, without the use of annotations, well thats what i was told.

If i'am wrong with any of my findings/statements please correct me, since currently i have to assume that i can not generate a metamodel without using annotations.

[Updated on: Wed, 25 May 2011 08:57]

Report message to a moderator

Re: Create Canonical Metamodel without using any JPA/EclipseLink Annotations [message #674002 is a reply to message #673419] Wed, 25 May 2011 13:45 Go to previous messageGo to next message
Neil Hauge is currently offline Neil HaugeFriend
Messages: 475
Registered: July 2009
Senior Member
This may or may not be helpful, but the Dali Tools in Eclipse offer JPA 2.0 metamodel generation that is not trigger by the standard annotation processor mechanism, but rather is based on the build (incremental or otherwise). So, every time you save/build we update the metamodel based on the JPA metadata specified in your project.

http://www.eclipse.org/webtools/releases/3.2.0/NewAndNoteworthy/jpa.php (search for "Metamodel Generation")

I did see that you were using Maven, which which may be an issue as Dali has some known issues with supporting Maven based projects. See http://www.eclipse.org/forums/index.php?t=msg&goto=508143&

Also, I would think there would be a way to run EclispeLink's metamodel generation from the command line. Perhaps someone will comment on that.

Neil
Re: Create Canonical Metamodel without using any JPA/EclipseLink Annotations [message #674106 is a reply to message #674002] Wed, 25 May 2011 20:41 Go to previous messageGo to next message
mgira  is currently offline mgira Friend
Messages: 6
Registered: May 2011
Junior Member
Hi Neil, thanks for the tip.

I tried the Dali Tools with some success (it doesn't recognize the maven structure properly), but the real problem is, that i need to be able to generate the Metamodel from a Maven Build, without having to use an Eclipse Plugin.
Re: Create Canonical Metamodel without using any JPA/EclipseLink Annotations [message #675179 is a reply to message #673419] Mon, 30 May 2011 14:08 Go to previous messageGo to next message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

The problem is that the APT compiler hook that allows the metamodel to be generated is based on annotations processing. So if you do not have any JPA annotations in any of the classes being compiled, then the compiler will not call on the metamodel generator.

So, you need at least one class that has a JPA annotation.

Please log a bug to track this issue. We should be able to have things generated even without usage of a JPA annotation, although, I'm not sure it is possible without any annotation, more investigation is needed.


James : Wiki : Book : Blog : Twitter
Re: Create Canonical Metamodel without using any JPA/EclipseLink Annotations [message #675392 is a reply to message #675179] Tue, 31 May 2011 11:23 Go to previous message
mgira  is currently offline mgira Friend
Messages: 6
Registered: May 2011
Junior Member
Hi James,

I've created the Bugreport(as enhancement) with the id 347760 (can't post links here yet).

Thanks for your support!
Previous Topic:Select via JPA (eclipselink) hangs on java.net.SocketInputStream.socketRead0(Native Method)
Next Topic:how to change default schema - postgresql
Goto Forum:
  


Current Time: Thu Apr 25 03:40:33 GMT 2024

Powered by FUDForum. Page generated in 0.03807 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top