reformatting due to loading inside XmlMind 4.1
This commit is contained in:
parent
9944b57de3
commit
44b7ef43d3
|
|
@ -1,7 +1,6 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
|
<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
|
||||||
"http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd">
|
"http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd">
|
||||||
|
|
||||||
<chapter id="orm">
|
<chapter id="orm">
|
||||||
<title>Object Relational Mapping (ORM) data access</title>
|
<title>Object Relational Mapping (ORM) data access</title>
|
||||||
|
|
||||||
|
|
@ -9,17 +8,17 @@
|
||||||
<title>Introduction</title>
|
<title>Introduction</title>
|
||||||
|
|
||||||
<para>The Spring Framework provides integration with <emphasis>Hibernate,
|
<para>The Spring Framework provides integration with <emphasis>Hibernate,
|
||||||
JDO, iBATIS SQL Maps</emphasis> and <emphasis>JPA</emphasis>: in terms
|
JDO, iBATIS SQL Maps</emphasis> and <emphasis>JPA</emphasis>: in terms of
|
||||||
of resource management, DAO implementation support, and
|
resource management, DAO implementation support, and transaction
|
||||||
transaction strategies. For example for Hibernate, there is
|
strategies. For example for Hibernate, there is first-class support with
|
||||||
first-class support with lots of IoC convenience features,
|
lots of IoC convenience features, addressing many typical Hibernate
|
||||||
addressing many typical Hibernate integration issues. All of
|
integration issues. All of these support packages for O/R (Object
|
||||||
these support packages for O/R (Object Relational) mappers comply with
|
Relational) mappers comply with Spring's generic transaction and DAO
|
||||||
Spring's generic transaction and DAO exception hierarchies. There are
|
exception hierarchies. There are usually two integration styles: either
|
||||||
usually two integration styles: either using Spring's DAO 'templates' or
|
using Spring's DAO 'templates' or coding DAOs against plain
|
||||||
coding DAOs against plain Hibernate/JDO/JPA/etc APIs. In both cases,
|
Hibernate/JDO/JPA/etc APIs. In both cases, DAOs can be configured through
|
||||||
DAOs can be configured through Dependency Injection and participate in
|
Dependency Injection and participate in Spring's resource and transaction
|
||||||
Spring's resource and transaction management.</para>
|
management.</para>
|
||||||
|
|
||||||
<para>Spring adds significant support when using the O/R mapping layer of
|
<para>Spring adds significant support when using the O/R mapping layer of
|
||||||
your choice to create data access applications. First of all, you should
|
your choice to create data access applications. First of all, you should
|
||||||
|
|
@ -102,10 +101,10 @@
|
||||||
|
|
||||||
<para>The PetClinic sample in the Spring distribution offers alternative
|
<para>The PetClinic sample in the Spring distribution offers alternative
|
||||||
DAO implementations and application context configurations for JDBC,
|
DAO implementations and application context configurations for JDBC,
|
||||||
Hibernate, and JPA. PetClinic can therefore serve as
|
Hibernate, and JPA. PetClinic can therefore serve as working sample app
|
||||||
working sample app that illustrates the use of Hibernate and JPA
|
that illustrates the use of Hibernate and JPA in a Spring web application.
|
||||||
in a Spring web application. It also leverages declarative transaction
|
It also leverages declarative transaction demarcation with different
|
||||||
demarcation with different transaction strategies.</para>
|
transaction strategies.</para>
|
||||||
|
|
||||||
<para>The JPetStore sample illustrates the use of iBATIS SQL Maps in a
|
<para>The JPetStore sample illustrates the use of iBATIS SQL Maps in a
|
||||||
Spring environment. It also features two web tier versions: one based on
|
Spring environment. It also features two web tier versions: one based on
|
||||||
|
|
@ -1297,8 +1296,8 @@
|
||||||
exposing a JDO transaction to JDBC access code that accesses the same
|
exposing a JDO transaction to JDBC access code that accesses the same
|
||||||
JDBC <interfacename>DataSource</interfacename>, provided that the
|
JDBC <interfacename>DataSource</interfacename>, provided that the
|
||||||
registered <classname>JdoDialect</classname> supports retrieval of the
|
registered <classname>JdoDialect</classname> supports retrieval of the
|
||||||
underlying JDBC <interfacename>Connection</interfacename>. This is
|
underlying JDBC <interfacename>Connection</interfacename>. This is the
|
||||||
the case for JDBC-based JDO 2.0 implementations by default.</para>
|
case for JDBC-based JDO 2.0 implementations by default.</para>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section id="orm-jdo-dialect">
|
<section id="orm-jdo-dialect">
|
||||||
|
|
@ -1345,7 +1344,8 @@
|
||||||
</itemizedlist>
|
</itemizedlist>
|
||||||
|
|
||||||
<para>See the <classname>JdoDialect</classname> Javadoc for more details
|
<para>See the <classname>JdoDialect</classname> Javadoc for more details
|
||||||
on its operations and how they are used within Spring's JDO support.</para>
|
on its operations and how they are used within Spring's JDO
|
||||||
|
support.</para>
|
||||||
</section>
|
</section>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
|
@ -1675,27 +1675,29 @@
|
||||||
|
|
||||||
</beans></programlisting>
|
</beans></programlisting>
|
||||||
|
|
||||||
<para>A typical <literal>persistence.xml</literal> file looks as follows:</para>
|
<para>A typical <literal>persistence.xml</literal> file looks as
|
||||||
|
follows:</para>
|
||||||
|
|
||||||
<programlisting language="xml"><persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
|
<programlisting language="xml"><persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
|
||||||
|
|
||||||
<persistence-unit name="myUnit" transaction-type="RESOURCE_LOCAL">
|
<persistence-unit name="myUnit" transaction-type="RESOURCE_LOCAL">
|
||||||
<mapping-file>META-INF/orm.xml</mapping-file>
|
<mapping-file>META-INF/orm.xml</mapping-file>
|
||||||
<exclude-unlisted-classes/>
|
<exclude-unlisted-classes/>
|
||||||
</persistence-unit>
|
</persistence-unit>
|
||||||
|
|
||||||
</persistence></programlisting>
|
</persistence></programlisting>
|
||||||
|
|
||||||
<para><emphasis>NOTE: The "exclude-unlisted-classes" element always
|
<para><emphasis>NOTE: The "exclude-unlisted-classes" element always
|
||||||
indicates that NO scanning for annotated entity classes is supposed
|
indicates that NO scanning for annotated entity classes is supposed to
|
||||||
to happen, in order to support the
|
happen, in order to support the
|
||||||
<literal><exclude-unlisted-classes/></literal> shortcut.
|
<literal><exclude-unlisted-classes/></literal> shortcut. This is
|
||||||
This is in line with the JPA specification (which suggests that shortcut)
|
in line with the JPA specification (which suggests that shortcut) but
|
||||||
but unfortunately in conflict with the JPA XSD (which implies "false"
|
unfortunately in conflict with the JPA XSD (which implies "false" for
|
||||||
for that shortcut). As a consequence,
|
that shortcut). As a consequence,
|
||||||
"<literal><exclude-unlisted-classes> false </exclude-unlisted-classes/></literal>"
|
"<literal><exclude-unlisted-classes> false
|
||||||
is not supported! Simply omit the "exclude-unlisted-classes" element if
|
</exclude-unlisted-classes/></literal>" is not supported! Simply
|
||||||
you would like entity class scanning to actually happen.</emphasis></para>
|
omit the "exclude-unlisted-classes" element if you would like entity
|
||||||
|
class scanning to actually happen.</emphasis></para>
|
||||||
|
|
||||||
<para>This is the most powerful JPA setup option, allowing for
|
<para>This is the most powerful JPA setup option, allowing for
|
||||||
flexible local configuration within the application. It supports links
|
flexible local configuration within the application. It supports links
|
||||||
|
|
@ -1751,22 +1753,22 @@
|
||||||
<interfacename>LoadTimeWeaver</interfacename> implementations for
|
<interfacename>LoadTimeWeaver</interfacename> implementations for
|
||||||
various environments, allowing
|
various environments, allowing
|
||||||
<interfacename>ClassTransformer</interfacename> instances to be
|
<interfacename>ClassTransformer</interfacename> instances to be
|
||||||
applied only <emphasis>per ClassLoader</emphasis> and not per VM.</para>
|
applied only <emphasis>per ClassLoader</emphasis> and not per
|
||||||
|
VM.</para>
|
||||||
|
|
||||||
<para>The following sections will discuss typical JPA weaving setup on
|
<para>The following sections will discuss typical JPA weaving setup on
|
||||||
Tomcat as well as using Spring's VM agent. See the AOP chapter section
|
Tomcat as well as using Spring's VM agent. See the AOP chapter section
|
||||||
entitled <xref linkend="aop-aj-ltw-spring"/> for details on how to set
|
entitled <xref linkend="aop-aj-ltw-spring" /> for details on how to
|
||||||
up general load-time weaving, covering Tomcat and the VM agent as well
|
set up general load-time weaving, covering Tomcat and the VM agent as
|
||||||
as WebLogic, OC4J, GlassFish and Resin.</para>
|
well as WebLogic, OC4J, GlassFish and Resin.</para>
|
||||||
|
|
||||||
<section id="orm-jpa-setup-lcemfb-tomcat">
|
<section id="orm-jpa-setup-lcemfb-tomcat">
|
||||||
<title>Tomcat load-time weaving setup (5.0+)</title>
|
<title>Tomcat load-time weaving setup (5.0+)</title>
|
||||||
|
|
||||||
<para><ulink url="http://tomcat.apache.org/">Apache
|
<para><ulink url="http://tomcat.apache.org/">Apache Tomcat's</ulink>
|
||||||
Tomcat's</ulink> default ClassLoader does not support class
|
default ClassLoader does not support class transformation but allows
|
||||||
transformation but allows custom ClassLoaders to be used. Spring
|
custom ClassLoaders to be used. Spring offers the
|
||||||
offers the <classname>TomcatInstrumentableClassLoader</classname>
|
<classname>TomcatInstrumentableClassLoader</classname> (inside the
|
||||||
(inside the
|
|
||||||
<literal>org.springframework.instrument.classloading.tomcat</literal>
|
<literal>org.springframework.instrument.classloading.tomcat</literal>
|
||||||
package) which extends the Tomcat ClassLoader
|
package) which extends the Tomcat ClassLoader
|
||||||
(<classname>WebappClassLoader</classname>) and allows JPA
|
(<classname>WebappClassLoader</classname>) and allows JPA
|
||||||
|
|
@ -1826,7 +1828,8 @@
|
||||||
|
|
||||||
<para>If you are using Tomcat 5.5.20+ you can set
|
<para>If you are using Tomcat 5.5.20+ you can set
|
||||||
<emphasis>useSystemClassLoaderAsParent</emphasis> to
|
<emphasis>useSystemClassLoaderAsParent</emphasis> to
|
||||||
<literal>false</literal> to fix the problem: <programlisting language="xml"><Context path="/myWebApp" docBase="/my/webApp/location">
|
<literal>false</literal> to fix the problem: <programlisting
|
||||||
|
language="xml"><Context path="/myWebApp" docBase="/my/webApp/location">
|
||||||
<Loader loaderClass="org.springframework.instrument.classloading.tomcat.TomcatInstrumentableClassLoader"
|
<Loader loaderClass="org.springframework.instrument.classloading.tomcat.TomcatInstrumentableClassLoader"
|
||||||
useSystemClassLoaderAsParent="false"/>
|
useSystemClassLoaderAsParent="false"/>
|
||||||
</Context></programlisting></para>
|
</Context></programlisting></para>
|
||||||
|
|
@ -1892,8 +1895,8 @@
|
||||||
other.</para>
|
other.</para>
|
||||||
|
|
||||||
<note>
|
<note>
|
||||||
<para>If TopLink Essentials is being used a JPA provider under Tomcat, please
|
<para>If TopLink Essentials is being used a JPA provider under
|
||||||
place the toplink-essentials jar under
|
Tomcat, please place the toplink-essentials jar under
|
||||||
<emphasis>$CATALINA_HOME</emphasis>/shared/lib folder instead of
|
<emphasis>$CATALINA_HOME</emphasis>/shared/lib folder instead of
|
||||||
your war.</para>
|
your war.</para>
|
||||||
</note>
|
</note>
|
||||||
|
|
@ -1924,14 +1927,17 @@
|
||||||
<section id="orm-jpa-setup-lcemfb-weaver">
|
<section id="orm-jpa-setup-lcemfb-weaver">
|
||||||
<title>Context-wide load-time weaver setup</title>
|
<title>Context-wide load-time weaver setup</title>
|
||||||
|
|
||||||
<para>Since Spring 2.5, a context-wide <interfacename>LoadTimeWeaver</interfacename>
|
<para>Since Spring 2.5, a context-wide
|
||||||
can be configured using the <literal>context:load-time-weaver</literal> configuration
|
<interfacename>LoadTimeWeaver</interfacename> can be configured
|
||||||
|
using the <literal>context:load-time-weaver</literal> configuration
|
||||||
element. Such a 'global' weaver will be picked up by all JPA
|
element. Such a 'global' weaver will be picked up by all JPA
|
||||||
<classname>LocalContainerEntityManagerFactoryBeans</classname> automatically.</para>
|
<classname>LocalContainerEntityManagerFactoryBeans</classname>
|
||||||
|
automatically.</para>
|
||||||
|
|
||||||
<para>This is the preferred way of setting up a load-time weaver, delivering
|
<para>This is the preferred way of setting up a load-time weaver,
|
||||||
autodetection of the platform (WebLogic, OC4J, GlassFish, Tomcat, Resin, VM agent)
|
delivering autodetection of the platform (WebLogic, OC4J, GlassFish,
|
||||||
as well as automatic propagation of the weaver to all weaver-aware beans.</para>
|
Tomcat, Resin, VM agent) as well as automatic propagation of the
|
||||||
|
weaver to all weaver-aware beans.</para>
|
||||||
|
|
||||||
<programlisting language="xml"><context:load-time-weaver/>
|
<programlisting language="xml"><context:load-time-weaver/>
|
||||||
|
|
||||||
|
|
@ -1939,11 +1945,11 @@
|
||||||
...
|
...
|
||||||
</bean></programlisting>
|
</bean></programlisting>
|
||||||
|
|
||||||
<para>See the section entitled <xref linkend="aop-aj-ltw-spring"/>
|
<para>See the section entitled <xref linkend="aop-aj-ltw-spring" />
|
||||||
for details on how to set up general load-time weaving, covering Tomcat
|
for details on how to set up general load-time weaving, covering
|
||||||
and the VM agent as well as WebLogic, OC4J, GlassFish and Resin.</para>
|
Tomcat and the VM agent as well as WebLogic, OC4J, GlassFish and
|
||||||
|
Resin.</para>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section id="orm-jpa-multiple-pu">
|
<section id="orm-jpa-multiple-pu">
|
||||||
|
|
@ -1984,12 +1990,12 @@
|
||||||
|
|
||||||
<para>Note that the default implementation allows customization of the
|
<para>Note that the default implementation allows customization of the
|
||||||
persistence unit infos before feeding them to the JPA provider
|
persistence unit infos before feeding them to the JPA provider
|
||||||
declaratively through its properties (which affect <emphasis>all</emphasis>
|
declaratively through its properties (which affect
|
||||||
hosted units) or programmatically, through the
|
<emphasis>all</emphasis> hosted units) or programmatically, through
|
||||||
<interfacename>PersistenceUnitPostProcessor</interfacename>
|
the <interfacename>PersistenceUnitPostProcessor</interfacename> (which
|
||||||
(which allows persistence unit selection). If no
|
allows persistence unit selection). If no
|
||||||
<interfacename>PersistenceUnitManager</interfacename> is
|
<interfacename>PersistenceUnitManager</interfacename> is specified,
|
||||||
specified, one will be created and used internally by
|
one will be created and used internally by
|
||||||
<classname>LocalContainerEntityManagerFactoryBean</classname>.</para>
|
<classname>LocalContainerEntityManagerFactoryBean</classname>.</para>
|
||||||
</section>
|
</section>
|
||||||
</section>
|
</section>
|
||||||
|
|
@ -2212,8 +2218,8 @@
|
||||||
|
|
||||||
<para>What about class level annotations?</para>
|
<para>What about class level annotations?</para>
|
||||||
|
|
||||||
<para>On the Java EE 5 platform, they are used for dependency declaration
|
<para>On the Java EE 5 platform, they are used for dependency
|
||||||
and not for resource injection.</para>
|
declaration and not for resource injection.</para>
|
||||||
</sidebar>
|
</sidebar>
|
||||||
|
|
||||||
<para>The injected <interfacename>EntityManager</interfacename> is
|
<para>The injected <interfacename>EntityManager</interfacename> is
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue