@@ -334,8 +334,8 @@ the `HibernateTransactionManager` needs a reference to the `SessionFactory`.
334334[source,xml,indent=0]
335335[subs="verbatim,quotes"]
336336----
337- <bean id="sessionFactory" class="org.springframework.orm.hibernate3 .LocalSessionFactoryBean">
338- <property name="dataSource" ref="dataSource" />
337+ <bean id="sessionFactory" class="org.springframework.orm.hibernate5 .LocalSessionFactoryBean">
338+ <property name="dataSource" ref="dataSource"/>
339339 <property name="mappingResources">
340340 <list>
341341 <value>org/springframework/samples/petclinic/hibernate/petclinic.hbm.xml</value>
@@ -348,8 +348,8 @@ the `HibernateTransactionManager` needs a reference to the `SessionFactory`.
348348 </property>
349349 </bean>
350350
351- <bean id="txManager" class="org.springframework.orm.hibernate3 .HibernateTransactionManager">
352- <property name="sessionFactory" ref="sessionFactory" />
351+ <bean id="txManager" class="org.springframework.orm.hibernate5 .HibernateTransactionManager">
352+ <property name="sessionFactory" ref="sessionFactory"/>
353353 </bean>
354354----
355355
@@ -2074,12 +2074,11 @@ the root exception. These exceptions wrap the original exception so there is nev
20742074risk that one might lose any information as to what might have gone wrong.
20752075
20762076In addition to JDBC exceptions, Spring can also wrap Hibernate-specific exceptions,
2077- converting them from proprietary, checked exceptions (in the case of versions of
2078- Hibernate prior to Hibernate 3.0), to a set of focused runtime exceptions (the same is
2079- true for JDO and JPA exceptions). This allows one to handle most persistence exceptions,
2080- which are non-recoverable, only in the appropriate layers, without having annoying
2081- boilerplate catch-and-throw blocks and exception declarations in one's DAOs. (One can
2082- still trap and handle exceptions anywhere one needs to though.) As mentioned above, JDBC
2077+ converting them to a set of focused runtime exceptions (the same is true for JDO and
2078+ JPA exceptions). This allows one to handle most persistence exceptions, which are
2079+ non-recoverable, only in the appropriate layers, without having annoying boilerplate
2080+ catch-and-throw blocks and exception declarations in one's DAOs. (One can still trap
2081+ and handle exceptions anywhere one needs to though.) As mentioned above, JDBC
20832082exceptions (including database-specific dialects) are also converted to the same
20842083hierarchy, meaning that one can perform some operations with JDBC within a consistent
20852084programming model.
@@ -5107,7 +5106,7 @@ exception hierarchies.
51075106
51085107[[orm-hibernate]]
51095108=== Hibernate
5110- We will start with a coverage of http://www.hibernate.org/[Hibernate 3 ] in a Spring
5109+ We will start with a coverage of http://www.hibernate.org/[Hibernate 5 ] in a Spring
51115110environment, using it to demonstrate the approach that Spring takes towards integrating
51125111O/R mappers. This section will cover many issues in detail and show different variations
51135112of DAO implementations and transaction demarcation. Most of these patterns can be
@@ -5116,7 +5115,7 @@ chapter will then cover the other ORM technologies, showing briefer examples the
51165115
51175116[NOTE]
51185117====
5119- As of Spring 4.0, Spring requires Hibernate 3.6 or later.
5118+ As of Spring 4.0, Spring requires Hibernate 3.6 or later. We recommend Hibernate 5.0+.
51205119====
51215120
51225121
@@ -5145,7 +5144,7 @@ JDBC `DataSource` and a Hibernate `SessionFactory` on top of it:
51455144 <property name="password" value=""/>
51465145 </bean>
51475146
5148- <bean id="mySessionFactory" class="org.springframework.orm.hibernate3 .LocalSessionFactoryBean">
5147+ <bean id="mySessionFactory" class="org.springframework.orm.hibernate5 .LocalSessionFactoryBean">
51495148 <property name="dataSource" ref="myDataSource"/>
51505149 <property name="mappingResources">
51515150 <list>
@@ -5181,8 +5180,8 @@ is typically not common outside of an EJB context.
51815180
51825181
51835182[[orm-hibernate-straight]]
5184- ==== Implementing DAOs based on plain Hibernate 3 API
5185- Hibernate 3 has a feature called contextual sessions, wherein Hibernate itself manages
5183+ ==== Implementing DAOs based on plain Hibernate API
5184+ Hibernate has a feature called contextual sessions, wherein Hibernate itself manages
51865185one current `Session` per transaction. This is roughly equivalent to Spring's
51875186synchronization of one Hibernate `Session` per transaction. A corresponding DAO
51885187implementation resembles the following example, based on the plain Hibernate API:
@@ -5251,7 +5250,7 @@ the return of the current `Session` associated with the ongoing JTA transaction,
52515250This behavior applies regardless of whether you are using Spring's
52525251`JtaTransactionManager`, EJB container managed transactions (CMTs), or JTA.
52535252
5254- In summary: you can implement DAOs based on the plain Hibernate 3 API, while still being
5253+ In summary: you can implement DAOs based on the plain Hibernate API, while still being
52555254able to participate in Spring-managed transactions.
52565255
52575256
@@ -5296,7 +5295,7 @@ XML, for a simple service class:
52965295 <!-- SessionFactory, DataSource, etc. omitted -->
52975296
52985297 <bean id="transactionManager"
5299- class="org.springframework.orm.hibernate3 .HibernateTransactionManager">
5298+ class="org.springframework.orm.hibernate5 .HibernateTransactionManager">
53005299 <property name="sessionFactory" ref="sessionFactory"/>
53015300 </bean>
53025301
@@ -5398,7 +5397,7 @@ provide is the TransactionManager implementation and a "<tx:annotation-driven/>"
53985397 <!-- SessionFactory, DataSource, etc. omitted -->
53995398
54005399 <bean id="transactionManager"
5401- class="org.springframework.orm.hibernate3 .HibernateTransactionManager">
5400+ class="org.springframework.orm.hibernate5 .HibernateTransactionManager">
54025401 <property name="sessionFactory" ref="sessionFactory"/>
54035402 </bean>
54045403
@@ -5429,7 +5428,7 @@ and an example for a business method implementation:
54295428----
54305429 <beans>
54315430
5432- <bean id="myTxManager" class="org.springframework.orm.hibernate3 .HibernateTransactionManager">
5431+ <bean id="myTxManager" class="org.springframework.orm.hibernate5 .HibernateTransactionManager">
54335432 <property name="sessionFactory" ref="mySessionFactory"/>
54345433 </bean>
54355434
@@ -5509,7 +5508,7 @@ long as it is using `JtaTransactionManager` as the strategy.
55095508 <jee:jndi-lookup id="dataSource2" jndi-name="java:comp/env/jdbc/myds2"/>
55105509
55115510 <bean id="mySessionFactory1"
5512- class="org.springframework.orm.hibernate3 .LocalSessionFactoryBean">
5511+ class="org.springframework.orm.hibernate5 .LocalSessionFactoryBean">
55135512 <property name="dataSource" ref="myDataSource1"/>
55145513 <property name="mappingResources">
55155514 <list>
@@ -5525,7 +5524,7 @@ long as it is using `JtaTransactionManager` as the strategy.
55255524 </bean>
55265525
55275526 <bean id="mySessionFactory2"
5528- class="org.springframework.orm.hibernate3 .LocalSessionFactoryBean">
5527+ class="org.springframework.orm.hibernate5 .LocalSessionFactoryBean">
55295528 <property name="dataSource" ref="myDataSource2"/>
55305529 <property name="mappingResources">
55315530 <list>
0 commit comments