I have a persistence.xml at src/main/resources/META-INF/ and another at src/test/... which differ only in the value of the database:
<properties>
<property name="hibernate.archive.autodetection" value="class, hbm"/>
<property name="hibernate.connection.url" value="jdbc:mysql://localhost/lanchecker-prod" />
and:
<properties>
<property name="hibernate.archive.autodetection" value="class, hbm"/>
<property name="hibernate.connection.url" value="jdbc:mysql://localhost/lanchecker-test" />
However I'm also using class autodetection which works fine for the main resource but fails when I use the test resource.
Is there any way to get this to work or am I obliged to use explicit class naming?
EDIT:
The linked suggestion doesn't actually work it it requires the project is built and tested as a .jar. In my case I'm attempting to do the testing under Eclipse, which can resolve the src/test/resources/META-INF/ location.
I tried adding:
<jar-file>${PROJECT_LOC}/src/main/java/biz/ianw/lanchecker/</jar-file>
but that resulted in:
Exception in thread "main" java.lang.ExceptionInInitializerError
...
Caused by: javax.persistence.PersistenceException: Unable to build entity manager factory
...
Caused by: java.lang.IllegalArgumentException: Unable to visit JAR file:${PROJECT_LOC}/src/main/java/biz/ianw/lanchecker/. Cause: Illegal character in opaque part at index 6: file:${PROJECT_LOC}/src/main/java/biz/ianw/lanchecker/
And then:
<jar-file>C:\Users\Ian\git\LANchecker\src\main\java\biz\ianw\lanchecker\</jar-file>
which passed entity manager factory startup, but still failed later with:
Exception in thread "main" java.lang.IllegalArgumentException: org.hibernate.hql.internal.ast.QuerySyntaxException: RouteCabinFares is not mapped [select rcf from RouteCabinFares rcf]
(RouteCabinFares is one of the classes I'm attempting to autolocate).
Maybe this technique can only be used to autolocate in jar files?