Updated reference documentation from Hibernate 3 to Hibernate 5

Issue: SPR-13230
This commit is contained in:
Juergen Hoeller 2015-12-18 00:27:19 +01:00
parent 0084c077bb
commit 2cfe00ce32
2 changed files with 21 additions and 22 deletions

View File

@ -334,8 +334,8 @@ the `HibernateTransactionManager` needs a reference to the `SessionFactory`.
[source,xml,indent=0] [source,xml,indent=0]
[subs="verbatim,quotes"] [subs="verbatim,quotes"]
---- ----
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <bean id="sessionFactory" class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource" /> <property name="dataSource" ref="dataSource"/>
<property name="mappingResources"> <property name="mappingResources">
<list> <list>
<value>org/springframework/samples/petclinic/hibernate/petclinic.hbm.xml</value> <value>org/springframework/samples/petclinic/hibernate/petclinic.hbm.xml</value>
@ -348,8 +348,8 @@ the `HibernateTransactionManager` needs a reference to the `SessionFactory`.
</property> </property>
</bean> </bean>
<bean id="txManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <bean id="txManager" class="org.springframework.orm.hibernate5.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" /> <property name="sessionFactory" ref="sessionFactory"/>
</bean> </bean>
---- ----
@ -2074,12 +2074,11 @@ the root exception. These exceptions wrap the original exception so there is nev
risk that one might lose any information as to what might have gone wrong. risk that one might lose any information as to what might have gone wrong.
In addition to JDBC exceptions, Spring can also wrap Hibernate-specific exceptions, In addition to JDBC exceptions, Spring can also wrap Hibernate-specific exceptions,
converting them from proprietary, checked exceptions (in the case of versions of converting them to a set of focused runtime exceptions (the same is true for JDO and
Hibernate prior to Hibernate 3.0), to a set of focused runtime exceptions (the same is JPA exceptions). This allows one to handle most persistence exceptions, which are
true for JDO and JPA exceptions). This allows one to handle most persistence exceptions, non-recoverable, only in the appropriate layers, without having annoying boilerplate
which are non-recoverable, only in the appropriate layers, without having annoying catch-and-throw blocks and exception declarations in one's DAOs. (One can still trap
boilerplate catch-and-throw blocks and exception declarations in one's DAOs. (One can and handle exceptions anywhere one needs to though.) As mentioned above, JDBC
still trap and handle exceptions anywhere one needs to though.) As mentioned above, JDBC
exceptions (including database-specific dialects) are also converted to the same exceptions (including database-specific dialects) are also converted to the same
hierarchy, meaning that one can perform some operations with JDBC within a consistent hierarchy, meaning that one can perform some operations with JDBC within a consistent
programming model. programming model.
@ -5107,7 +5106,7 @@ exception hierarchies.
[[orm-hibernate]] [[orm-hibernate]]
=== Hibernate === Hibernate
We will start with a coverage of http://www.hibernate.org/[Hibernate 3] in a Spring We will start with a coverage of http://www.hibernate.org/[Hibernate 5] in a Spring
environment, using it to demonstrate the approach that Spring takes towards integrating environment, using it to demonstrate the approach that Spring takes towards integrating
O/R mappers. This section will cover many issues in detail and show different variations O/R mappers. This section will cover many issues in detail and show different variations
of DAO implementations and transaction demarcation. Most of these patterns can be 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
[NOTE] [NOTE]
==== ====
As of Spring 4.0, Spring requires Hibernate 3.6 or later. As of Spring 4.0, Spring requires Hibernate 3.6 or later. We recommend Hibernate 5.0+.
==== ====
@ -5145,7 +5144,7 @@ JDBC `DataSource` and a Hibernate `SessionFactory` on top of it:
<property name="password" value=""/> <property name="password" value=""/>
</bean> </bean>
<bean id="mySessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <bean id="mySessionFactory" class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
<property name="dataSource" ref="myDataSource"/> <property name="dataSource" ref="myDataSource"/>
<property name="mappingResources"> <property name="mappingResources">
<list> <list>
@ -5181,8 +5180,8 @@ is typically not common outside of an EJB context.
[[orm-hibernate-straight]] [[orm-hibernate-straight]]
==== Implementing DAOs based on plain Hibernate 3 API ==== Implementing DAOs based on plain Hibernate API
Hibernate 3 has a feature called contextual sessions, wherein Hibernate itself manages Hibernate has a feature called contextual sessions, wherein Hibernate itself manages
one current `Session` per transaction. This is roughly equivalent to Spring's one current `Session` per transaction. This is roughly equivalent to Spring's
synchronization of one Hibernate `Session` per transaction. A corresponding DAO synchronization of one Hibernate `Session` per transaction. A corresponding DAO
implementation resembles the following example, based on the plain Hibernate API: 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,
This behavior applies regardless of whether you are using Spring's This behavior applies regardless of whether you are using Spring's
`JtaTransactionManager`, EJB container managed transactions (CMTs), or JTA. `JtaTransactionManager`, EJB container managed transactions (CMTs), or JTA.
In summary: you can implement DAOs based on the plain Hibernate 3 API, while still being In summary: you can implement DAOs based on the plain Hibernate API, while still being
able to participate in Spring-managed transactions. able to participate in Spring-managed transactions.
@ -5296,7 +5295,7 @@ XML, for a simple service class:
<!-- SessionFactory, DataSource, etc. omitted --> <!-- SessionFactory, DataSource, etc. omitted -->
<bean id="transactionManager" <bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager"> class="org.springframework.orm.hibernate5.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory"/> <property name="sessionFactory" ref="sessionFactory"/>
</bean> </bean>
@ -5398,7 +5397,7 @@ provide is the TransactionManager implementation and a "<tx:annotation-driven/>"
<!-- SessionFactory, DataSource, etc. omitted --> <!-- SessionFactory, DataSource, etc. omitted -->
<bean id="transactionManager" <bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager"> class="org.springframework.orm.hibernate5.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory"/> <property name="sessionFactory" ref="sessionFactory"/>
</bean> </bean>
@ -5429,7 +5428,7 @@ and an example for a business method implementation:
---- ----
<beans> <beans>
<bean id="myTxManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <bean id="myTxManager" class="org.springframework.orm.hibernate5.HibernateTransactionManager">
<property name="sessionFactory" ref="mySessionFactory"/> <property name="sessionFactory" ref="mySessionFactory"/>
</bean> </bean>
@ -5509,7 +5508,7 @@ long as it is using `JtaTransactionManager` as the strategy.
<jee:jndi-lookup id="dataSource2" jndi-name="java:comp/env/jdbc/myds2"/> <jee:jndi-lookup id="dataSource2" jndi-name="java:comp/env/jdbc/myds2"/>
<bean id="mySessionFactory1" <bean id="mySessionFactory1"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
<property name="dataSource" ref="myDataSource1"/> <property name="dataSource" ref="myDataSource1"/>
<property name="mappingResources"> <property name="mappingResources">
<list> <list>
@ -5525,7 +5524,7 @@ long as it is using `JtaTransactionManager` as the strategy.
</bean> </bean>
<bean id="mySessionFactory2" <bean id="mySessionFactory2"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
<property name="dataSource" ref="myDataSource2"/> <property name="dataSource" ref="myDataSource2"/>
<property name="mappingResources"> <property name="mappingResources">
<list> <list>

View File

@ -2873,7 +2873,7 @@ this:
<property name="sessionFactory" ref="sessionFactory"/> <property name="sessionFactory" ref="sessionFactory"/>
</bean> </bean>
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <bean id="sessionFactory" class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
<!-- configuration elided for brevity --> <!-- configuration elided for brevity -->
</bean> </bean>