See attached for test case. In a typical maven project, in folder main/resources/META-INF/persistence.xml, a persistence unit is defined, with 'hibernate.hbm2ddl.auto=validate'. For testing purposes, in folder src/test/resources/META-INF/persistence.xml, a persistence unit with same name is defined, with 'hibernate.hbm2ddl.auto=create'. Unit tests are falling, because no table exists. Unit tests will pass after any of the 2 changes:
- update hibernate.hbm2ddl.auto to 'create' in main/resources/META-INF/persistence.xml
- switch hibernate version to 4.3.5.Final.
Thus, properties from main/resources/META-INF/persistence.xml are considered in maven test phase, and not from test/resources/META-INF/persistence.xml. This can be reproduced in hibernate orm version 5.2.10.Final, and not 4.3.5.Final. |