@@ -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
@@ -1296,7 +1296,7 @@ These default settings can be changed; the various properties of the `@Transacti
1296
1296
annotation are summarized in the following table:
1297
1297
1298
1298
[[tx-attransactional-properties]]
1299
- .@
1299
+ .@Transactional Settings
1300
1300
|===
1301
1301
| Property| Type| Description
1302
1302
@@ -1778,7 +1778,7 @@ a transaction. You then pass an instance of your custom `TransactionCallback` to
1778
1778
1779
1779
// use constructor-injection to supply the PlatformTransactionManager
1780
1780
public SimpleService(PlatformTransactionManager transactionManager) {
1781
- Assert.notNull(transactionManager, "The '' transactionManager' ' argument must not be null.");
1781
+ Assert.notNull(transactionManager, "The 'transactionManager' argument must not be null.");
1782
1782
this.transactionTemplate = new TransactionTemplate(transactionManager);
1783
1783
}
1784
1784
@@ -1845,7 +1845,7 @@ a specific `TransactionTemplate:`
1845
1845
private final TransactionTemplate transactionTemplate;
1846
1846
1847
1847
public SimpleService(PlatformTransactionManager transactionManager) {
1848
- Assert.notNull(transactionManager, "The '' transactionManager' ' argument must not be null.");
1848
+ Assert.notNull(transactionManager, "The 'transactionManager' argument must not be null.");
1849
1849
this.transactionTemplate = new TransactionTemplate(transactionManager);
1850
1850
1851
1851
// the transaction settings can be set here explicitly if so desired
@@ -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.
@@ -2919,10 +2918,6 @@ query methods, one for an `int` and one that queries for a `String`.
2919
2918
public String getName() {
2920
2919
return this.jdbcTemplate.queryForObject("select name from mytable", String.class);
2921
2920
}
2922
-
2923
- public void setDataSource(DataSource dataSource) {
2924
- this.dataSource = dataSource;
2925
- }
2926
2921
}
2927
2922
----
2928
2923
@@ -5107,7 +5102,7 @@ exception hierarchies.
5107
5102
5108
5103
[[orm-hibernate]]
5109
5104
=== Hibernate
5110
- We will start with a coverage of http://www.hibernate.org/[Hibernate 3 ] in a Spring
5105
+ We will start with a coverage of http://www.hibernate.org/[Hibernate 5 ] in a Spring
5111
5106
environment, using it to demonstrate the approach that Spring takes towards integrating
5112
5107
O/R mappers. This section will cover many issues in detail and show different variations
5113
5108
of DAO implementations and transaction demarcation. Most of these patterns can be
@@ -5116,7 +5111,9 @@ chapter will then cover the other ORM technologies, showing briefer examples the
5116
5111
5117
5112
[NOTE]
5118
5113
====
5119
- As of Spring 4.0, Spring requires Hibernate 3.6 or later.
5114
+ As of Spring 4.0, Spring requires Hibernate 3.6 or later. Note that the Hibernate team
5115
+ stopped supporting Hibernate 3 years ago and even phased out support for Hibernate 4.x
5116
+ in late 2015. We therefore recommend Hibernate 5.1 and higher from a 2016+ perspective.
5120
5117
====
5121
5118
5122
5119
@@ -5145,7 +5142,7 @@ JDBC `DataSource` and a Hibernate `SessionFactory` on top of it:
5145
5142
<property name="password" value=""/>
5146
5143
</bean>
5147
5144
5148
- <bean id="mySessionFactory" class="org.springframework.orm.hibernate3 .LocalSessionFactoryBean">
5145
+ <bean id="mySessionFactory" class="org.springframework.orm.hibernate5 .LocalSessionFactoryBean">
5149
5146
<property name="dataSource" ref="myDataSource"/>
5150
5147
<property name="mappingResources">
5151
5148
<list>
@@ -5181,8 +5178,8 @@ is typically not common outside of an EJB context.
5181
5178
5182
5179
5183
5180
[[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
5181
+ ==== Implementing DAOs based on plain Hibernate API
5182
+ Hibernate has a feature called contextual sessions, wherein Hibernate itself manages
5186
5183
one current `Session` per transaction. This is roughly equivalent to Spring's
5187
5184
synchronization of one Hibernate `Session` per transaction. A corresponding DAO
5188
5185
implementation resembles the following example, based on the plain Hibernate API:
@@ -5251,7 +5248,7 @@ the return of the current `Session` associated with the ongoing JTA transaction,
5251
5248
This behavior applies regardless of whether you are using Spring's
5252
5249
`JtaTransactionManager`, EJB container managed transactions (CMTs), or JTA.
5253
5250
5254
- In summary: you can implement DAOs based on the plain Hibernate 3 API, while still being
5251
+ In summary: you can implement DAOs based on the plain Hibernate API, while still being
5255
5252
able to participate in Spring-managed transactions.
5256
5253
5257
5254
@@ -5296,7 +5293,7 @@ XML, for a simple service class:
5296
5293
<!-- SessionFactory, DataSource, etc. omitted -->
5297
5294
5298
5295
<bean id="transactionManager"
5299
- class="org.springframework.orm.hibernate3 .HibernateTransactionManager">
5296
+ class="org.springframework.orm.hibernate5 .HibernateTransactionManager">
5300
5297
<property name="sessionFactory" ref="sessionFactory"/>
5301
5298
</bean>
5302
5299
@@ -5398,7 +5395,7 @@ provide is the TransactionManager implementation and a "<tx:annotation-driven/>"
5398
5395
<!-- SessionFactory, DataSource, etc. omitted -->
5399
5396
5400
5397
<bean id="transactionManager"
5401
- class="org.springframework.orm.hibernate3 .HibernateTransactionManager">
5398
+ class="org.springframework.orm.hibernate5 .HibernateTransactionManager">
5402
5399
<property name="sessionFactory" ref="sessionFactory"/>
5403
5400
</bean>
5404
5401
@@ -5429,7 +5426,7 @@ and an example for a business method implementation:
5429
5426
----
5430
5427
<beans>
5431
5428
5432
- <bean id="myTxManager" class="org.springframework.orm.hibernate3 .HibernateTransactionManager">
5429
+ <bean id="myTxManager" class="org.springframework.orm.hibernate5 .HibernateTransactionManager">
5433
5430
<property name="sessionFactory" ref="mySessionFactory"/>
5434
5431
</bean>
5435
5432
@@ -5509,7 +5506,7 @@ long as it is using `JtaTransactionManager` as the strategy.
5509
5506
<jee:jndi-lookup id="dataSource2" jndi-name="java:comp/env/jdbc/myds2"/>
5510
5507
5511
5508
<bean id="mySessionFactory1"
5512
- class="org.springframework.orm.hibernate3 .LocalSessionFactoryBean">
5509
+ class="org.springframework.orm.hibernate5 .LocalSessionFactoryBean">
5513
5510
<property name="dataSource" ref="myDataSource1"/>
5514
5511
<property name="mappingResources">
5515
5512
<list>
@@ -5525,7 +5522,7 @@ long as it is using `JtaTransactionManager` as the strategy.
5525
5522
</bean>
5526
5523
5527
5524
<bean id="mySessionFactory2"
5528
- class="org.springframework.orm.hibernate3 .LocalSessionFactoryBean">
5525
+ class="org.springframework.orm.hibernate5 .LocalSessionFactoryBean">
5529
5526
<property name="dataSource" ref="myDataSource2"/>
5530
5527
<property name="mappingResources">
5531
5528
<list>
0 commit comments