Creating metamodel classes using maven and eclipse (JPA, Maven, Eclipse)

I use m2e (1.0.100), Eclipse (Indigo SR1) and hibernate-jpamodelgen (1.1.1.Final).
I want hibernate to generate the Canonical metamodel from my objects when compiling projects.
I was able to do this earlier when I was working on a project other than maven, and I followed numerous tutorials on how to set up an eclipse project to use this jar.
However, as far as I know, using m2e is best (necessary?) So that it can create an eclipse configuration for you, and therefore I'm not sure how to do it.
This hibernate tutorial explains how to use the generator with maven and eclipse, but separately.
I think that what I am missing is to glue my pom, which was generated as simple without the pom archetype, and my eclipse project configuration so that they allow me to do JPA magic.
BTW, following the above guide for maven, caused my maven-created jars to contain classes, but they are not visible to eclipse, since they are only in jars and not in real projects.

Thank you in advance

+4
source share
1 answer

I asked the same question on the m2e-users mailing list and got the following answer ( link for those who want to get the full stream):

Basically, you need to manually configure (e.g. using the aforementioned hibernation tutorial) eclipse to use the generator and configure the same directory that uses maven (for me it was target / generated sources / annotations) as the output directory.

According to the m2e committers, the project does not currently modify these eclipse files, and therefore it will not be undone from them.

The problem I ran into was that this information is lost (and therefore manual change is required again) when using GIT and switching between branches, since I don't want to transfer any eclipse related files to SCM. <w> This is currently an acceptable solution, and I hope m2e can add this missing feature.

Update
Information lost, at least in my experience, is identifying the target/generated-sources/annotations folder as the source folder. Just like FYI.

+1
source

Source: https://habr.com/ru/post/1386361/


All Articles