1

I was going going to use some JPA Entities in various apps, so I placed them in a separate JAR and added dependencies in pom where needed. In order to allow persistence provider to "see" the entities classes I had to clearly list them in the persistence.xml (I'm using EclipseLink). And what is more interesting, I had to list all custom converters there as well:

<class>my.app.persistence.Entity</class>
<class>my.app.persistence.MapToJsonConverter</class>
<class>my.app.persistence.UuidConverter</class>

That's fine, but the question is, if there is a more elegant way to make classes visible for the persistence provider if they come via Maven dependency? I tried the "jar-file" property:

<jar-file>my-app-persistence.jar</jar-file>

But it didn't work because EclipseLink was looking for the my-app-persistence.jar file in the target folder of the main app (while it was in the local Maven repo).

Sogawa-sps
  • 147
  • 10
  • This might be what you're searching for - but it's an older project which seems to be inactive. But you could give it a try: https://github.com/agapsys/jpa-scanner-maven-plugin – majusebetter Sep 01 '22 at 22:35
  • Thank you @majusebetter I've read the info in that github project including referenced discussion https://stackoverflow.com/questions/4433341/what-is-the-right-path-to-refer-a-jar-file-in-jpa-persistence-xml-in-a-web-app/6522308 It looks like there is no OOB way to do it simpler indeed, and a jpa-scanner plugin doesn't seem to be stable enough. So manual listing of all classes is the only way :) – Sogawa-sps Sep 02 '22 at 17:25

0 Answers0