简体   繁体   中英

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

I'm using m2e (1.0.100), Eclipse (Indigo SR1) and hibernate-jpamodelgen (1.1.1.Final).
I want to have hibernate generate the Canonical metamodel from my entities when I compile the projects.
I was able to do this previously when I was working on a non-maven project and I followed the numerous tutorials there are on how to configure the eclipse project to use this jar.
However, to the best of my understanding, when using m2e it is best (mandatory?) to let it do the eclipse configuration for you and so I'm not sure how this should be done.
This hibernate tutorial explains how to use the generator with maven and eclipse but separately.
I think what I'm missing is gluing my pom, which was generated as a simple no archetype pom, and my eclipse project configuration so that they enable me to do some JPA magic.
BTW, following the above tutorial for maven caused my maven-generated jars to contain the _ classes but these are not seen by eclipse since they are only in the jars and not in the actual projects.

Thanks in advance

I've asked the same question on the m2e-users mailing list and got the following answer ( link for those wanting the full thread):

Basically one should manually configure (for example using the above mentioned hibernate tutorial) eclipse to use the generator and configure the same directory maven uses (for me it was target/generated-sources/annotations) as the output directory.

According to the committers of m2e, the project currently does not change these eclipse files and so this won't be overriden from them.

The problem I did face was that this information is lost (and so the manual change is needed again) when using GIT and switching between branches as I don't want to commit any eclipse related files to the SCM.
Currently this is an acceptable solution and I hope m2e will be able to add this missing feature.

Update
The information that is lost, at least according to my experience, is the definition of the target/generated-sources/annotations folder as a source folder. Just as an FYI.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM