diff --git a/src/docbkx/reference/jpa.xml b/src/docbkx/reference/jpa.xml index c23aa4460..bec4b8585 100644 --- a/src/docbkx/reference/jpa.xml +++ b/src/docbkx/reference/jpa.xml @@ -883,5 +883,45 @@ public interface UserRepository extends JpaRepository<User, Long> { </bean> + +
+ Classpath scanning for @Entity classes and JPA mapping + files + + A plain JPA setup requires all annotation mapped entity classes + listed in orm.xml. Same applies to XML mapping + files. Spring Data JPA provides a + ClasspathScanningPersistenceUnitPostProcessor + that gets a base package configured and optionally takes a mapping + filename pattern. It will then scan the given package for classes + annotated with @Entity or + @MappedSuperclass and also loads the + configuration files matching the filename pattern and hands them to the + JPA configuration. The PostProcessor has to be configured like + this + + + Using ClasspathScanningPersistenceUnitPostProcessor + + <bean class="….LocalContainerEntityManagerFactoryBean"> + <property name="persistenceUnitPostProcessors"> + <list> + <bean class="org.springframework.data.jpa.support.ClasspathScanningPersistenceUnitPostProcessor"> + <constructor-arg value="com.acme.domain" /> + <property name="mappingFileNamePattern" value="**/*Mapping.xml" /> + </bean> + </list> + </property> +</bean> + + + + As of Spring 3.1 a package to scan can be configured on the + LocalContainerEntityManagerFactoryBean directly + to enable classpath scanning for entity classes. See the JavaDoc + for details. + +
\ No newline at end of file