Is that possible to change the folder that JPA Metamodel generates? By default, it puts on "target/generated-sources/annotations". For me it's strange to generate them inside "target", I would like to map it in git, target is not a folder to be commited.
And I'd like to configure to change the package too, to be in a diferente location of the original classes.
Related
Currently all generated java files and gen folder are marked as derived so I'm not able to checkin these files. Is there any compiler arg or confguration which I can use to disable this marking in maven-compiler-plugin?
If it is not possible to achieve it with maven-compiler-plugin is there any plugin which could generate the code without marking the files as derived?
My entities objects are scattered in multiple jars.
In jar A I have a base class name MyBase which is annotated with #MappedSuperclass.
In jar B there is an entity class which derives from MyBase.
The problem is that because the weaving is done in the context of the jar file (I'm using the maven plugin) the base class (MyBase) isn't instrumented (although it should).
If I move the derived class from jar B to A then the weaving process will handle the base as well.
Since I'm working on a large project it is critical for me to develop in a modular way.
Doesn't EclipseLink support such methodology?
The only way I found to override this limitation is to add a temporary entity class to the jar where the #MappedSuperclass base class is defined and remove it after the weaving procedure.
Sad, but true ;-)
I'm not sure on the maven plugin, but you should be able to use the static weaver on both jars, you will need to call it twice to weave both, and will need both jars on the weavers classpath for both calls.
Alternatively you can specify the jar containing your superclass as inpath - as explained here and here:
Managing multiple projects
Building AspectJ source code requires two distinct phases; compiling
the source in .java and .aj files to generate .class files, and then
applying the aspects to the generated .class files. This second phase,
known as weaving, is the key difference between AspectJ and Java
compilers. The Java compilation process is controlled by the classpath
setting, which makes types available for resolution by the compiler.
The same classpath setting is used by the AspectJ compilation process
and it is configured in exactly the same way in Eclipse. However, this
setting is not sufficient to control both the compilation and weaving
steps in all situations. This is why there are two extra settings
available for AspectJ projects.
First, there is the inpath setting. Anything specified here will be
made available to the weaver and so any aspects that apply will be
woven in. Entries can be added to a project's inpath by right-clicking
on the project, selecting Properties, then going to the AspectJ InPath
section. Entries can be either JAR files or directories (class
folders), such as the bin directory of another project. Anything on
the inpath is sent to the project's output, after potentially being
woven with aspects.
The second additional setting is the aspectpath. Whereas the inpath
controls the list of things that get woven, the aspectpath controls
what is woven into that list. In other words, any aspects specified on
the aspectpath are made available to the weaving process, just as if
they were present in source form in the project. This setting is
controlled from the AspectJ Aspect Path property page and can contain
either JAR files or directories.
An output JAR setting is also present in the AspectJ section of each
project's property page. This setting causes the compiler to output
class files directly to a JAR file, instead of to the project's output
folder.
Drove me crazy just like you - hope this helps. ;)
I have read this on how to auto-generate the Entity Meta Model, but I think there is something wrong.
I have: Eclipse Indigo SR2, build 20120216-1857 and configured the "Annotation Processor" as specified here. To the factory path I have added ONLY these jars
hibernate-jpamodelgen-1.2.0.Final.jar (taken from here)
hibernate-jpa-2.0-api-1.0.1.Final.jar (taken from the zip archive of Hibernate ORM 4.1.0 from here)
I suppose after configuring this for my the EJB project (I did not do that for my Web or EAR Project), the project gets rebuild and the Meta Model Classes will be autogenerated, without clicking on another button, is that right?
If everything should have worked, do you have any clues on what could go wrong?
Notes:
I see absolutely no messages from any annotation processors in the "Error Log" Eclipse View.
My persistence.xml file is in the ejbModule/META-INF/persistence.xml
All my entities extend an Abstract class, imported in the project with svn:externals.
My entities are annotated with #Entity, and that's all.
The problem is that the project has also AspectJ compatibility, which makes the Project use another compiler. More details on this bug here.
Beside that, you could (bun not mandatory you will) get an NullPointerException (see the "Error Log" Eclipse View) if you have at least an Abstract Class in your project.
You just need to select the source folder of the generated metamodel on your Project -> Properties -> JPA
Is there any method to create a virtual file resource in eclipse?
By my definition, such a resource would appear (for Eclipse) to reside at a certain location within the Eclipse project's workspace, but is actually stored somewhere else.
My overall goal is to resolve xml schema documents from project dependencies (jar imports) based on their relative import location. I can accomplish this goal, but now I need a way to make those resolved documents visible in the project folder (within the Eclipse project) relative to the document that imported them without actually writing them to the source folder (they shouldn't be checked-in to source control).
The goal is to allow xml documents to resolve properly in the various eclipse editors, while allowing some of the referenced documents (XSDs and the like) to reside within archives on the project's classpath (or anywhere else such that they're referenced by the project, really).
My initial plan of attack is to create a custom builder plugin which would resolve such documents into virtual resources as the build path was changed. (assuming that such a "virtual file resource" is something that can be created).
Any help is appreciated.
IPath location = new Path(name);
IFile file = project.getFile(location.lastSegment());
file.createLink(location, IResource.NONE, null);
seems to be the way to do it;
http://help.eclipse.org/juno/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Fguide%2FresInt_virtual.htm
I'm currently using Eclipse Indigo and I'd like to have my meta-model classes to be automatically generated in a sub-package instead of having them in the same package of my entities.
I've followed the instructions in the JPA User Guide for Canonical Model Generator on Eclipse Galileo, but it's not working at all with Indigo. :(
Does anybody use the static meta-model classes in a sub-package? Is there any way to configure it on Eclipse Indigo?
Maybe you should not change package
I would suggest against it, because having those in sub package (or any other) violates current JPA 2 specification:
• For each managed class X in package p, a metamodel class X_ in
package p is created.[67]
...
[67] We expect that the option of
different packages will be provided in a future release of this
specification.
...
Implementations of this specification are not
required to support the use of non-canonical metamodel classes.
Applications that use non-canonical metamodel classes will not be
portable.
Other way to organize is common JUnit practice: same package in different source directory.
But if you have to, this is how it is done
Following works at least with Eclipse version: Indigo Service Release 1 20110916-0149 and EclipseLink: eclipselink-2.3.0.v20110604-r9504. Names of the JARs can slightly vary from version to another.
If enabled, disable generating to the same package where entities are:
Go to Project Properties - JPA and check that value of Source Folder
is <None>
Adjusting generating to the other package:
Properties - Annotation Processing
[x] Enable project specific settings
[x] Enable annotation processing
[x] Enable processing in editor
Generated source directory: src (or wherever sources live)
New processor option:
key=eclipselink.canonicalmodel.subpackage
value=sub | (desired package name)
Go one level deeper to the Annotation Processing | Factory Path and select Add External JARs and add following jars:
eclipselink/jlib/jpajavax.persistence_2.0.3.v201010191057.jar
eclipselink/jlib/jpaeclipselink-jpa-modelgen_2.3.0.v20110604-r9504.jar
eclipselink/jlib/eclipselink.jar
Let Eclipse rebuild project.