@@ -334,8 +334,8 @@ the `HibernateTransactionManager` needs a reference to the `SessionFactory`.
334
334
[source,xml,indent=0]
335
335
[subs="verbatim,quotes"]
336
336
----
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"/>
339
339
<property name="mappingResources">
340
340
<list>
341
341
<value>org/springframework/samples/petclinic/hibernate/petclinic.hbm.xml</value>
@@ -348,8 +348,8 @@ the `HibernateTransactionManager` needs a reference to the `SessionFactory`.
348
348
</property>
349
349
</bean>
350
350
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"/>
353
353
</bean>
354
354
----
355
355
@@ -2074,12 +2074,11 @@ the root exception. These exceptions wrap the original exception so there is nev
2074
2074
risk that one might lose any information as to what might have gone wrong.
2075
2075
2076
2076
In 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
2083
2082
exceptions (including database-specific dialects) are also converted to the same
2084
2083
hierarchy, meaning that one can perform some operations with JDBC within a consistent
2085
2084
programming model.
@@ -5107,7 +5106,7 @@ exception hierarchies.
5107
5106
5108
5107
[[orm-hibernate]]
5109
5108
=== 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
5111
5110
environment, using it to demonstrate the approach that Spring takes towards integrating
5112
5111
O/R mappers. This section will cover many issues in detail and show different variations
5113
5112
of 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
5116
5115
5117
5116
[NOTE]
5118
5117
====
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+.
5120
5119
====
5121
5120
5122
5121
@@ -5145,7 +5144,7 @@ JDBC `DataSource` and a Hibernate `SessionFactory` on top of it:
5145
5144
<property name="password" value=""/>
5146
5145
</bean>
5147
5146
5148
- <bean id="mySessionFactory" class="org.springframework.orm.hibernate3 .LocalSessionFactoryBean">
5147
+ <bean id="mySessionFactory" class="org.springframework.orm.hibernate5 .LocalSessionFactoryBean">
5149
5148
<property name="dataSource" ref="myDataSource"/>
5150
5149
<property name="mappingResources">
5151
5150
<list>
@@ -5181,8 +5180,8 @@ is typically not common outside of an EJB context.
5181
5180
5182
5181
5183
5182
[[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
5186
5185
one current `Session` per transaction. This is roughly equivalent to Spring's
5187
5186
synchronization of one Hibernate `Session` per transaction. A corresponding DAO
5188
5187
implementation 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,
5251
5250
This behavior applies regardless of whether you are using Spring's
5252
5251
`JtaTransactionManager`, EJB container managed transactions (CMTs), or JTA.
5253
5252
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
5255
5254
able to participate in Spring-managed transactions.
5256
5255
5257
5256
@@ -5296,7 +5295,7 @@ XML, for a simple service class:
5296
5295
<!-- SessionFactory, DataSource, etc. omitted -->
5297
5296
5298
5297
<bean id="transactionManager"
5299
- class="org.springframework.orm.hibernate3 .HibernateTransactionManager">
5298
+ class="org.springframework.orm.hibernate5 .HibernateTransactionManager">
5300
5299
<property name="sessionFactory" ref="sessionFactory"/>
5301
5300
</bean>
5302
5301
@@ -5398,7 +5397,7 @@ provide is the TransactionManager implementation and a "<tx:annotation-driven/>"
5398
5397
<!-- SessionFactory, DataSource, etc. omitted -->
5399
5398
5400
5399
<bean id="transactionManager"
5401
- class="org.springframework.orm.hibernate3 .HibernateTransactionManager">
5400
+ class="org.springframework.orm.hibernate5 .HibernateTransactionManager">
5402
5401
<property name="sessionFactory" ref="sessionFactory"/>
5403
5402
</bean>
5404
5403
@@ -5429,7 +5428,7 @@ and an example for a business method implementation:
5429
5428
----
5430
5429
<beans>
5431
5430
5432
- <bean id="myTxManager" class="org.springframework.orm.hibernate3 .HibernateTransactionManager">
5431
+ <bean id="myTxManager" class="org.springframework.orm.hibernate5 .HibernateTransactionManager">
5433
5432
<property name="sessionFactory" ref="mySessionFactory"/>
5434
5433
</bean>
5435
5434
@@ -5509,7 +5508,7 @@ long as it is using `JtaTransactionManager` as the strategy.
5509
5508
<jee:jndi-lookup id="dataSource2" jndi-name="java:comp/env/jdbc/myds2"/>
5510
5509
5511
5510
<bean id="mySessionFactory1"
5512
- class="org.springframework.orm.hibernate3 .LocalSessionFactoryBean">
5511
+ class="org.springframework.orm.hibernate5 .LocalSessionFactoryBean">
5513
5512
<property name="dataSource" ref="myDataSource1"/>
5514
5513
<property name="mappingResources">
5515
5514
<list>
@@ -5525,7 +5524,7 @@ long as it is using `JtaTransactionManager` as the strategy.
5525
5524
</bean>
5526
5525
5527
5526
<bean id="mySessionFactory2"
5528
- class="org.springframework.orm.hibernate3 .LocalSessionFactoryBean">
5527
+ class="org.springframework.orm.hibernate5 .LocalSessionFactoryBean">
5529
5528
<property name="dataSource" ref="myDataSource2"/>
5530
5529
<property name="mappingResources">
5531
5530
<list>
0 commit comments