4

I have two Eclipse Maven Java projects. A domain project that is laden with JPA annotations and a persist project that implements DAOs for the domain objects. The persist project depends on the domain project. Maven compiles everything and it all Just Works.

My JPA persistence.xml file is located in the persist project however, and the Eclipse JPA (Dali) plugin thus works with the persist project, but for the domain project it complains that the project has no persistence.xml file. I'd really like to get the JPA Details and JPA structure views working in my domain project. Whats the best way to work around this?

I tried linking the META-INF folder from persist to domain, but that didn't work.

Karen Butzke
  • 1,442
  • 12
  • 18
Dave
  • 21,524
  • 28
  • 141
  • 221

2 Answers2

1
  1. Right click on projects
  2. Click "project facets" on the left
  3. Check if JPA facet is checked
  4. After checking you will need to define the persistence.xml path I think alt text
Gábor Lipták
  • 9,646
  • 2
  • 59
  • 113
  • 1
    I've been all over that dialog box, but I can find no place to set the persistence.xml path. That would be awesome were it so... – Dave Nov 18 '10 at 15:59
  • After checking below an information is displayed, that further configuration is needed. – Gábor Lipták Nov 18 '10 at 16:20
  • 1
    Yes - that further configuration involves setting up JPA. This allows one to select the platform, provide an implementation library, customize database connection, etc., etc. But no setting a path to persistence.xml that I can see. – Dave Nov 18 '10 at 16:42
1

Move the persistence.xml to the domain module and just don't use Dali in the persist module.

Since persist depends on domain, the system builds and runs fine because JPA is able to locate the persistence.xml file in the domain JAR file without difficulty.

Dave
  • 21,524
  • 28
  • 141
  • 221
  • This turned out to be fine for me as I don't really need the Dali views in the persist module. Now if you had JPA annotated domain entities across multiple projects that would be a different issue...but then the solution would probably be to have multiple persistence.xml files. – Dave Jun 14 '16 at 14:23