added language element to programlisting for syntax highlighting
This commit is contained in:
@@ -192,7 +192,7 @@
|
||||
JDBC <classname>DataSource</classname> and a Hibernate
|
||||
<interfacename>SessionFactory</interfacename> on top of it:</para>
|
||||
|
||||
<programlisting><beans>
|
||||
<programlisting language="xml"><beans>
|
||||
|
||||
<bean id="myDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
|
||||
<property name="driverClassName" value="org.hsqldb.jdbcDriver"/>
|
||||
@@ -222,7 +222,7 @@
|
||||
<interfacename>DataSource</interfacename> (usually managed by an
|
||||
application server) is just a matter of configuration:</para>
|
||||
|
||||
<programlisting><beans>
|
||||
<programlisting language="xml"><beans>
|
||||
|
||||
<bean id="myDataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
|
||||
<property name="jndiName" value="java:comp/env/jdbc/myds"/>
|
||||
@@ -251,7 +251,7 @@
|
||||
<interfacename>SessionFactory</interfacename>, and an example for a DAO
|
||||
method implementation.</para>
|
||||
|
||||
<programlisting><beans>
|
||||
<programlisting language="xml"><beans>
|
||||
|
||||
<bean id="myProductDao" class="product.ProductDaoImpl">
|
||||
<property name="sessionFactory" ref="mySessionFactory"/>
|
||||
@@ -259,7 +259,7 @@
|
||||
|
||||
</beans></programlisting>
|
||||
|
||||
<programlisting>public class ProductDaoImpl implements ProductDao {
|
||||
<programlisting language="java">public class ProductDaoImpl implements ProductDao {
|
||||
|
||||
private HibernateTemplate hibernateTemplate;
|
||||
|
||||
@@ -280,7 +280,7 @@
|
||||
that are not exposed on the <classname>HibernateTemplate</classname>,
|
||||
you can always drop down to a callback-based approach like so.</para>
|
||||
|
||||
<programlisting>public class ProductDaoImpl implements ProductDao {
|
||||
<programlisting language="java">public class ProductDaoImpl implements ProductDao {
|
||||
|
||||
private HibernateTemplate hibernateTemplate;
|
||||
|
||||
@@ -319,7 +319,7 @@
|
||||
combination, this allows for very simple DAO implementations for typical
|
||||
requirements:</para>
|
||||
|
||||
<programlisting>public class ProductDaoImpl extends HibernateDaoSupport implements ProductDao {
|
||||
<programlisting language="java">public class ProductDaoImpl extends HibernateDaoSupport implements ProductDao {
|
||||
|
||||
public Collection loadProductsByCategory(String category) throws DataAccessException {
|
||||
return this.getHibernateTemplate().find(
|
||||
@@ -349,7 +349,7 @@
|
||||
<interfacename>Session</interfacename>, as its lifecycle is managed by
|
||||
the transaction).</para>
|
||||
|
||||
<programlisting>public class HibernateProductDao extends HibernateDaoSupport implements ProductDao {
|
||||
<programlisting language="java">public class HibernateProductDao extends HibernateDaoSupport implements ProductDao {
|
||||
|
||||
public Collection loadProductsByCategory(String category) throws DataAccessException, MyException {
|
||||
Session session = getSession(false);
|
||||
@@ -391,7 +391,7 @@
|
||||
DAO implementation looks like as follows, based on the plain Hibernate
|
||||
API:</para>
|
||||
|
||||
<programlisting>public class ProductDaoImpl implements ProductDao {
|
||||
<programlisting language="java">public class ProductDaoImpl implements ProductDao {
|
||||
|
||||
private SessionFactory sessionFactory;
|
||||
|
||||
@@ -424,7 +424,7 @@
|
||||
with the desired factory reference. As a Spring bean definition, it
|
||||
would look as follows:</para>
|
||||
|
||||
<programlisting><beans>
|
||||
<programlisting language="xml"><beans>
|
||||
|
||||
<bean id="myProductDao" class="product.ProductDaoImpl">
|
||||
<property name="sessionFactory" ref="mySessionFactory"/>
|
||||
@@ -480,7 +480,7 @@
|
||||
a Spring application context, and an example for a business method
|
||||
implementation.</para>
|
||||
|
||||
<programlisting><beans>
|
||||
<programlisting language="xml"><beans>
|
||||
|
||||
<bean id="myTxManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
|
||||
<property name="sessionFactory" ref="mySessionFactory"/>
|
||||
@@ -493,7 +493,7 @@
|
||||
|
||||
</beans></programlisting>
|
||||
|
||||
<programlisting>public class ProductServiceImpl implements ProductService {
|
||||
<programlisting language="java">public class ProductServiceImpl implements ProductService {
|
||||
|
||||
private TransactionTemplate transactionTemplate;
|
||||
private ProductDao productDao;
|
||||
@@ -533,7 +533,7 @@
|
||||
configuration file and do not affect the business service
|
||||
implementations.</para>
|
||||
|
||||
<programlisting><beans>
|
||||
<programlisting language="xml"><beans>
|
||||
|
||||
<bean id="myTxManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
|
||||
<property name="sessionFactory" ref="mySessionFactory"/>
|
||||
@@ -555,7 +555,7 @@
|
||||
|
||||
</beans></programlisting>
|
||||
|
||||
<programlisting>public class ProductServiceImpl implements ProductService {
|
||||
<programlisting language="java">public class ProductServiceImpl implements ProductService {
|
||||
|
||||
private ProductDao productDao;
|
||||
|
||||
@@ -593,7 +593,7 @@
|
||||
have not done so already prior to continuing.</para>
|
||||
</note>
|
||||
|
||||
<programlisting><?xml version="1.0" encoding="UTF-8"?>
|
||||
<programlisting language="xml"><?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:aop="http://www.springframework.org/schema/aop"
|
||||
@@ -663,7 +663,7 @@
|
||||
factories without special regard, as long as it is using
|
||||
<classname>JtaTransactionManager</classname> as the strategy.</para>
|
||||
|
||||
<programlisting><beans>
|
||||
<programlisting language="xml"><beans>
|
||||
|
||||
<bean id="myDataSource1" class="org.springframework.jndi.JndiObjectFactoryBean">
|
||||
<property name="jndiName value="java:comp/env/jdbc/myds1"/>
|
||||
@@ -963,7 +963,7 @@
|
||||
<interfacename>PersistenceManagerFactory</interfacename> within a Spring
|
||||
application context:</para>
|
||||
|
||||
<programlisting><beans>
|
||||
<programlisting language="xml"><beans>
|
||||
|
||||
<bean id="myPmf" class="org.springframework.orm.jdo.LocalPersistenceManagerFactoryBean">
|
||||
<property name="configLocation" value="classpath:kodo.properties"/>
|
||||
@@ -984,7 +984,7 @@
|
||||
"connectionFactory" property. For example, for the open source JDO
|
||||
implementation JPOX (<ulink url="http://www.jpox.org"></ulink>):</para>
|
||||
|
||||
<programlisting><beans>
|
||||
<programlisting language="xml"><beans>
|
||||
|
||||
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
|
||||
<property name="driverClassName" value="${jdbc.driverClassName}"/>
|
||||
@@ -1025,7 +1025,7 @@
|
||||
usually rather be used with the Spring Framework's
|
||||
<classname>JdoTemplate</classname>:</para>
|
||||
|
||||
<programlisting><beans>
|
||||
<programlisting language="xml"><beans>
|
||||
|
||||
<bean id="myProductDao" class="product.ProductDaoImpl">
|
||||
<property name="persistenceManagerFactory" ref="myPmf"/>
|
||||
@@ -1033,7 +1033,7 @@
|
||||
|
||||
</beans></programlisting>
|
||||
|
||||
<programlisting>public class ProductDaoImpl implements ProductDao {
|
||||
<programlisting language="java">public class ProductDaoImpl implements ProductDao {
|
||||
|
||||
private JdoTemplate jdoTemplate;
|
||||
|
||||
@@ -1073,7 +1073,7 @@
|
||||
combination, this allows for very simple DAO implementations for typical
|
||||
requirements:</para>
|
||||
|
||||
<programlisting>public class ProductDaoImpl extends JdoDaoSupport implements ProductDao {
|
||||
<programlisting language="java">public class ProductDaoImpl extends JdoDaoSupport implements ProductDao {
|
||||
|
||||
public Collection loadProductsByCategory(String category) throws DataAccessException {
|
||||
return getJdoTemplate().find(
|
||||
@@ -1101,7 +1101,7 @@
|
||||
<interfacename>PersistenceManagerFactory</interfacename>. A
|
||||
corresponding DAO implementation looks like as follows:</para>
|
||||
|
||||
<programlisting>public class ProductDaoImpl implements ProductDao {
|
||||
<programlisting language="java">public class ProductDaoImpl implements ProductDao {
|
||||
|
||||
private PersistenceManagerFactory persistenceManagerFactory;
|
||||
|
||||
@@ -1126,7 +1126,7 @@
|
||||
it still fits nicely into a Spring container, just like it would if
|
||||
coded against Spring's <classname>JdoTemplate</classname>:</para>
|
||||
|
||||
<programlisting><beans>
|
||||
<programlisting language="xml"><beans>
|
||||
|
||||
<bean id="myProductDao" class="product.ProductDaoImpl">
|
||||
<property name="persistenceManagerFactory" ref="myPmf"/>
|
||||
@@ -1143,7 +1143,7 @@
|
||||
<interfacename>PersistenceManagerFactory</interfacename>, passing the
|
||||
proxy into your DAOs.</para>
|
||||
|
||||
<programlisting><beans>
|
||||
<programlisting language="xml"><beans>
|
||||
|
||||
<bean id="myPmfProxy"
|
||||
class="org.springframework.orm.jdo.TransactionAwarePersistenceManagerFactoryProxy">
|
||||
@@ -1173,7 +1173,7 @@
|
||||
call and thus the entire <literal>finally</literal> block, which you
|
||||
might prefer to keep your DAO implementations concise:</para>
|
||||
|
||||
<programlisting>public class ProductDaoImpl implements ProductDao {
|
||||
<programlisting language="java">public class ProductDaoImpl implements ProductDao {
|
||||
|
||||
private PersistenceManagerFactory persistenceManagerFactory;
|
||||
|
||||
@@ -1194,7 +1194,7 @@
|
||||
<classname>TransactionAwarePersistenceManagerFactoryProxy</classname>'s
|
||||
"allowCreate" flag off:</para>
|
||||
|
||||
<programlisting><beans>
|
||||
<programlisting language="xml"><beans>
|
||||
|
||||
<bean id="myPmfProxy"
|
||||
class="org.springframework.orm.jdo.TransactionAwarePersistenceManagerFactoryProxy">
|
||||
@@ -1238,7 +1238,7 @@
|
||||
<para>To execute service operations within transactions, you can use
|
||||
Spring's common declarative transaction facilities. For example:</para>
|
||||
|
||||
<programlisting><?xml version="1.0" encoding="UTF-8"?>
|
||||
<programlisting language="xml"><?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans
|
||||
xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
@@ -1375,7 +1375,7 @@
|
||||
Spring-managed JDBC <interfacename>DataSource</interfacename> to
|
||||
use.</para>
|
||||
|
||||
<programlisting><beans>
|
||||
<programlisting language="xml"><beans>
|
||||
|
||||
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
|
||||
<property name="driverClassName" value="${jdbc.driverClassName}"/>
|
||||
@@ -1391,7 +1391,7 @@
|
||||
|
||||
</beans></programlisting>
|
||||
|
||||
<programlisting><toplink-configuration>
|
||||
<programlisting language="xml"><toplink-configuration>
|
||||
|
||||
<session>
|
||||
<name>Session</name>
|
||||
@@ -1428,7 +1428,7 @@
|
||||
<interfacename>SessionFactory</interfacename>, but will usually rather
|
||||
be used with Spring's <literal>TopLinkTemplate</literal>:</para>
|
||||
|
||||
<programlisting><beans>
|
||||
<programlisting language="xml"><beans>
|
||||
|
||||
<bean id="myProductDao" class="product.ProductDaoImpl">
|
||||
<property name="sessionFactory" ref="mySessionFactory"/>
|
||||
@@ -1436,7 +1436,7 @@
|
||||
|
||||
</beans></programlisting>
|
||||
|
||||
<programlisting>public class TopLinkProductDao implements ProductDao {
|
||||
<programlisting language="java">public class TopLinkProductDao implements ProductDao {
|
||||
|
||||
private TopLinkTemplate tlTemplate;
|
||||
|
||||
@@ -1482,7 +1482,7 @@
|
||||
combination, this allows for simple DAO implementations for typical
|
||||
requirements:</para>
|
||||
|
||||
<programlisting>public class ProductDaoImpl extends TopLinkDaoSupport implements ProductDao {
|
||||
<programlisting language="java">public class ProductDaoImpl extends TopLinkDaoSupport implements ProductDao {
|
||||
|
||||
public Collection loadProductsByCategory(String category) throws DataAccessException {
|
||||
ReadAllQuery findOwnersQuery = new ReadAllQuery(Product.class);
|
||||
@@ -1535,7 +1535,7 @@
|
||||
|
||||
<para>A corresponding DAO implementation looks like as follows:</para>
|
||||
|
||||
<programlisting>public class ProductDaoImpl implements ProductDao {
|
||||
<programlisting language="java">public class ProductDaoImpl implements ProductDao {
|
||||
|
||||
private Session session;
|
||||
|
||||
@@ -1564,7 +1564,7 @@
|
||||
bean reference of type <interfacename>Session</interfacename>, to be
|
||||
passed into the DAO:</para>
|
||||
|
||||
<programlisting><beans>
|
||||
<programlisting language="xml"><beans>
|
||||
|
||||
<bean id="mySessionAdapter"
|
||||
class="org.springframework.orm.toplink.support.TransactionAwareSessionAdapter">
|
||||
@@ -1627,7 +1627,7 @@
|
||||
<para>To execute service operations within transactions, you can use
|
||||
Spring's common declarative transaction facilities. For example:</para>
|
||||
|
||||
<programlisting><?xml version="1.0" encoding="UTF-8"?>
|
||||
<programlisting language="xml"><?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans
|
||||
xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
@@ -1730,7 +1730,7 @@
|
||||
need to create the following SQL map
|
||||
<filename>'Account.xml'</filename>:</para>
|
||||
|
||||
<programlisting><sqlMap namespace="Account">
|
||||
<programlisting language="xml"><sqlMap namespace="Account">
|
||||
|
||||
<resultMap id="result" class="examples.Account">
|
||||
<result property="name" column="NAME" columnIndex="1"/>
|
||||
@@ -1751,7 +1751,7 @@
|
||||
|
||||
<para>The configuration file for iBATIS 2 looks like this:</para>
|
||||
|
||||
<programlisting><sqlMapConfig>
|
||||
<programlisting language="xml"><sqlMapConfig>
|
||||
|
||||
<sqlMap resource="example/Account.xml"/>
|
||||
|
||||
@@ -1767,7 +1767,7 @@
|
||||
<classname>SqlMapClientFactoryBean</classname>, which enables lazy
|
||||
loading.</para>
|
||||
|
||||
<programlisting><beans>
|
||||
<programlisting language="xml"><beans>
|
||||
|
||||
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
|
||||
<property name="driverClassName" value="${jdbc.driverClassName}"/>
|
||||
@@ -1792,7 +1792,7 @@
|
||||
supporting class similar to the <classname>SqlMapDaoSupport</classname>.
|
||||
We extend it to implement our DAO:</para>
|
||||
|
||||
<programlisting>public class SqlMapAccountDao extends SqlMapClientDaoSupport implements AccountDao {
|
||||
<programlisting language="java">public class SqlMapAccountDao extends SqlMapClientDaoSupport implements AccountDao {
|
||||
|
||||
public Account getAccount(String email) throws DataAccessException {
|
||||
return (Account) getSqlMapClientTemplate().queryForObject("getAccountByEmail", email);
|
||||
@@ -1809,7 +1809,7 @@
|
||||
application context and wiring it with our
|
||||
<literal>SqlMapClient</literal> instance:</para>
|
||||
|
||||
<programlisting><beans>
|
||||
<programlisting language="xml"><beans>
|
||||
|
||||
<bean id="accountDao" class="example.SqlMapAccountDao">
|
||||
<property name="sqlMapClient" ref="sqlMapClient"/>
|
||||
@@ -1828,7 +1828,7 @@
|
||||
<literal>SqlMapClientCallback</literal> implementation as argument. This
|
||||
can, for example, be used for batching:</para>
|
||||
|
||||
<programlisting>public class SqlMapAccountDao extends SqlMapClientDaoSupport implements AccountDao {
|
||||
<programlisting language="java">public class SqlMapAccountDao extends SqlMapClientDaoSupport implements AccountDao {
|
||||
|
||||
public void insertAccount(Account account) throws DataAccessException {
|
||||
getSqlMapClientTemplate().execute(new SqlMapClientCallback() {
|
||||
@@ -1857,7 +1857,7 @@
|
||||
<literal>SqlMapClient</literal>. A corresponding DAO implementation
|
||||
looks like as follows:</para>
|
||||
|
||||
<programlisting>public class SqlMapAccountDao implements AccountDao {
|
||||
<programlisting language="java">public class SqlMapAccountDao implements AccountDao {
|
||||
|
||||
private SqlMapClient sqlMapClient;
|
||||
|
||||
@@ -1891,7 +1891,7 @@
|
||||
that the plain iBATIS-based DAO still follows the Dependency Injection
|
||||
pattern:</para>
|
||||
|
||||
<programlisting><beans>
|
||||
<programlisting language="xml"><beans>
|
||||
|
||||
<bean id="accountDao" class="example.SqlMapAccountDao">
|
||||
<property name="sqlMapClient" ref="sqlMapClient"/>
|
||||
@@ -1929,7 +1929,7 @@
|
||||
and, in most cases, requires only the persistence unit name to be
|
||||
specified:</para>
|
||||
|
||||
<programlisting><beans>
|
||||
<programlisting language="xml"><beans>
|
||||
|
||||
<bean id="myEmf" class="org.springframework.orm.jpa.LocalEntityManagerFactoryBean">
|
||||
<property name="persistenceUnitName" value="myPersistenceUnit"/>
|
||||
@@ -1959,7 +1959,7 @@
|
||||
from JNDI (for example in a Java EE 5 environment), is just a matter
|
||||
of changing the XML configuration:</para>
|
||||
|
||||
<programlisting><beans>
|
||||
<programlisting language="xml"><beans>
|
||||
|
||||
<jee:jndi-lookup id="myEmf" jndi-name="persistence/myPersistenceUnit"/>
|
||||
|
||||
@@ -2013,7 +2013,7 @@
|
||||
custom DataSources outside of JNDI and to control the weaving
|
||||
process.</para>
|
||||
|
||||
<programlisting><beans>
|
||||
<programlisting language="xml"><beans>
|
||||
|
||||
<bean id="myEmf" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
|
||||
<property name="dataSource" ref="someDataSource"/>
|
||||
@@ -2026,7 +2026,7 @@
|
||||
|
||||
<para>A typical <literal>persistence.xml</literal> file looks as follows:</para>
|
||||
|
||||
<programlisting><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">
|
||||
<mapping-file>META-INF/orm.xml</mapping-file>
|
||||
@@ -2144,7 +2144,7 @@
|
||||
of the default one) by editing the web application context
|
||||
file:</para>
|
||||
|
||||
<programlisting><Context path="/myWebApp" docBase="/my/webApp/location">
|
||||
<programlisting language="xml"><Context path="/myWebApp" docBase="/my/webApp/location">
|
||||
<Loader loaderClass="org.springframework.instrument.classloading.tomcat.TomcatInstrumentableClassLoader"/>
|
||||
</Context></programlisting>
|
||||
|
||||
@@ -2175,7 +2175,7 @@
|
||||
|
||||
<para>If you are using Tomcat 5.5.20+ you can set
|
||||
<emphasis>useSystemClassLoaderAsParent</emphasis> to
|
||||
<literal>false</literal> to fix the problem: <programlisting><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"
|
||||
useSystemClassLoaderAsParent="false"/>
|
||||
</Context></programlisting></para>
|
||||
@@ -2199,7 +2199,7 @@
|
||||
of the default one) by editing the web application context
|
||||
file:</para>
|
||||
|
||||
<programlisting><Context path="/myWebApp" docBase="/my/webApp/location">
|
||||
<programlisting language="xml"><Context path="/myWebApp" docBase="/my/webApp/location">
|
||||
<Loader loaderClass="org.springframework.instrument.classloading.tomcat.TomcatInstrumentableClassLoader"/>
|
||||
</Context></programlisting>
|
||||
|
||||
@@ -2227,7 +2227,7 @@
|
||||
configuring
|
||||
<classname>LocalContainerEntityManagerFactoryBean</classname>:</para>
|
||||
|
||||
<programlisting><bean id="emf" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
|
||||
<programlisting language="xml"><bean id="emf" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
|
||||
<property name="loadTimeWeaver">
|
||||
<bean class="org.springframework.instrument.classloading.ReflectiveLoadTimeWeaver"/>
|
||||
</property>
|
||||
@@ -2258,7 +2258,7 @@
|
||||
a Spring-specific (but very general) VM agent (<filename
|
||||
class="libraryfile">spring-agent.jar</filename>):</para>
|
||||
|
||||
<programlisting><bean id="emf" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
|
||||
<programlisting language="xml"><bean id="emf" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
|
||||
<property name="loadTimeWeaver">
|
||||
<bean class="org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver"/>
|
||||
</property>
|
||||
@@ -2282,7 +2282,7 @@
|
||||
autodetection of the platform (WebLogic, OC4J, GlassFish, Tomcat, Resin, VM agent)
|
||||
as well as automatic propagation of the weaver to all weaver-aware beans.</para>
|
||||
|
||||
<programlisting><context:load-time-weaver/>
|
||||
<programlisting language="xml"><context:load-time-weaver/>
|
||||
|
||||
<bean id="emf" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
|
||||
...
|
||||
@@ -2309,7 +2309,7 @@
|
||||
parsed and later on retrieved through the persistence unit
|
||||
name:</para>
|
||||
|
||||
<programlisting><bean id="pum" class="org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager">
|
||||
<programlisting language="xml"><bean id="pum" class="org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager">
|
||||
<property name="persistenceXmlLocation">
|
||||
<list>
|
||||
<value>org/springframework/orm/jpa/domain/persistence-multi.xml</value>
|
||||
@@ -2353,7 +2353,7 @@
|
||||
given <interfacename>EntityManagerFactory</interfacename> or through
|
||||
Spring's <classname>JpaTemplate</classname>:</para>
|
||||
|
||||
<programlisting><beans>
|
||||
<programlisting language="xml"><beans>
|
||||
|
||||
<bean id="myProductDao" class="product.ProductDaoImpl">
|
||||
<property name="entityManagerFactory" ref="myEmf"/>
|
||||
@@ -2361,7 +2361,7 @@
|
||||
|
||||
</beans></programlisting>
|
||||
|
||||
<programlisting>public class JpaProductDao implements ProductDao {
|
||||
<programlisting language="java">public class JpaProductDao implements ProductDao {
|
||||
|
||||
private JpaTemplate jpaTemplate;
|
||||
|
||||
@@ -2401,7 +2401,7 @@
|
||||
<methodname>getJpaTemplate()</methodname> to be used by
|
||||
subclasses:</para>
|
||||
|
||||
<programlisting>public class ProductDaoImpl extends JpaDaoSupport implements ProductDao {
|
||||
<programlisting language="java">public class ProductDaoImpl extends JpaDaoSupport implements ProductDao {
|
||||
|
||||
public Collection loadProductsByCategory(String category) throws DataAccessException {
|
||||
Map<String, String> params = new HashMap<String, String>();
|
||||
@@ -2457,7 +2457,7 @@
|
||||
<classname>PersistenceAnnotationBeanPostProcessor</classname> is
|
||||
enabled. A corresponding DAO implementation might look like this:</para>
|
||||
|
||||
<programlisting>public class ProductDaoImpl implements ProductDao {
|
||||
<programlisting language="java">public class ProductDaoImpl implements ProductDao {
|
||||
|
||||
private EntityManagerFactory emf;
|
||||
|
||||
@@ -2487,7 +2487,7 @@
|
||||
advantage of annotations to require the injection of the default
|
||||
<interfacename>EntityManagerFactory</interfacename>:</para>
|
||||
|
||||
<programlisting><beans>
|
||||
<programlisting language="xml"><beans>
|
||||
|
||||
<lineannotation><!-- bean post-processor for JPA annotations --></lineannotation>
|
||||
<bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor"/>
|
||||
@@ -2505,7 +2505,7 @@
|
||||
(including <classname>CommonAnnotationBeanPostProcessor</classname>
|
||||
etc).</para>
|
||||
|
||||
<programlisting><beans>
|
||||
<programlisting language="xml"><beans>
|
||||
|
||||
<lineannotation><!-- post-processors for all standard config annotations --></lineannotation>
|
||||
<context:annotation-config/>
|
||||
@@ -2522,7 +2522,7 @@
|
||||
transactional EntityManager) to be injected instead of the
|
||||
factory:</para>
|
||||
|
||||
<programlisting>public class ProductDaoImpl implements ProductDao {
|
||||
<programlisting language="java">public class ProductDaoImpl implements ProductDao {
|
||||
|
||||
@PersistenceContext
|
||||
private EntityManager em;
|
||||
@@ -2597,14 +2597,14 @@
|
||||
exception translation to be applied transparently through the
|
||||
<interfacename>@Repository</interfacename> annotation:</para>
|
||||
|
||||
<programlisting>@Repository
|
||||
<programlisting language="java">@Repository
|
||||
public class ProductDaoImpl implements ProductDao {
|
||||
|
||||
<lineannotation>// class body here...</lineannotation>
|
||||
|
||||
}</programlisting>
|
||||
|
||||
<programlisting><beans>
|
||||
<programlisting language="xml"><beans>
|
||||
|
||||
<lineannotation><!-- <classname>Exception</classname> translation bean post processor --></lineannotation>
|
||||
<bean class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor"/>
|
||||
@@ -2635,7 +2635,7 @@ public class ProductDaoImpl implements ProductDao {
|
||||
<para>To execute service operations within transactions, you can use
|
||||
Spring's common declarative transaction facilities. For example:</para>
|
||||
|
||||
<programlisting><?xml version="1.0" encoding="UTF-8"?>
|
||||
<programlisting language="xml"><?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:aop="http://www.springframework.org/schema/aop"
|
||||
|
||||
Reference in New Issue
Block a user