DATAJPA-123, DATAJPA-122 - Updated reference documentation.
Added documentation of ClasspathScanningPersistenceUnitPostProcessor to reference documentation.
This commit is contained in:
@@ -883,5 +883,45 @@ public interface UserRepository extends JpaRepository<User, Long> {
|
||||
</bean></programlisting></para>
|
||||
</example>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<title>Classpath scanning for @Entity classes and JPA mapping
|
||||
files</title>
|
||||
|
||||
<para>A plain JPA setup requires all annotation mapped entity classes
|
||||
listed in <filename>orm.xml</filename>. Same applies to XML mapping
|
||||
files. Spring Data JPA provides a
|
||||
<classname>ClasspathScanningPersistenceUnitPostProcessor</classname>
|
||||
that gets a base package configured and optionally takes a mapping
|
||||
filename pattern. It will then scan the given package for classes
|
||||
annotated with <interfacename>@Entity</interfacename> or
|
||||
<interfacename>@MappedSuperclass</interfacename> 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</para>
|
||||
|
||||
<example>
|
||||
<title>Using ClasspathScanningPersistenceUnitPostProcessor</title>
|
||||
|
||||
<para><programlisting language="xml"><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></programlisting></para>
|
||||
</example>
|
||||
|
||||
<note>
|
||||
<para>As of Spring 3.1 a package to scan can be configured on the
|
||||
<classname>LocalContainerEntityManagerFactoryBean</classname> directly
|
||||
to enable classpath scanning for entity classes. See the <ulink
|
||||
url="http://static.springsource.org/spring/docs/3.1.x/javadoc-api/org/springframework/orm/jpa/LocalContainerEntityManagerFactoryBean.html#setPackagesToScan(java.lang.String...)">JavaDoc</ulink>
|
||||
for details.</para>
|
||||
</note>
|
||||
</section>
|
||||
</section>
|
||||
</chapter>
|
||||
Reference in New Issue
Block a user