hibernate - How to enable classpath scanning for @Entity classes in Spring boot -
all attempts @ classpath scanning of @entity classes failed in spring boot application. common solution found on web , didn't work -
localcontainerentitymanagerfactorybean factory = new localcontainerentitymanagerfactorybean(); factory.setjpavendoradapter(vendoradapter); factory.setpackagestoscan("com.acme.domain");
@entityscan on @configuration class did not work either.
all entities , mappings listed in orm.xml , had move using @entity annotations.
one solution got me half way there -
<persistence-unit> <provider>org.hibernate.ejb.hibernatepersistence</provider> <mapping-file>meta-inf/orm.xml</mapping-file> <class>com.acme.domain.entity</class> <shared-cache-mode>none</shared-cache-mode> </persistence-unit>
this way use @entity annotations if listed entity classes in persistence.xml.
the solution didn't find while searching, listed on spring data jpa web page -
classpathscanningpersistenceunitpostprocessor postprocessor = new classpathscanningpersistenceunitpostprocessor("com.acme.domain"); entitymanagerfactory.setpersistenceunitpostprocessors(postprocessor);
now classpath scanning of @entity classes enabled. no mappings in orm.xml , no listing of entities in persistence.xml.
Comments
Post a Comment