
|
If you were logged in you would be able to see more operations.
|
|
|
|
Hibernate 3.2 (as of CR3) has deprecated FlushMode.NEVER in favor of FlushMode.MANUAL. It seems it is purely a renaming (i.e., they have the same level of 0), but both still exist and they're distinct objects. Thus, using FlushMode.MANUAL in favor of FlushMode.NEVER will cause unexpected behavior in many hibernate-related Spring classes, which still are only checking for FlushMode.NEVER. The classes where this could be a problem include:
org.springframework.orm.hibernate3
- HibernateAccessor
- HibernateTemplate
- HibernateTransactionManager
- SessionFactoryUtils
- SpringSessionSynchronization
org.springframework.orm.hibernate3.support
- OpenSessionInViewFilter
For example, our app, which makes heavy use of both Spring and Hibernate, recently started using Spring 2.0 cr4 and Hibernate 3.2 cr4. When I replaced all occurrences of FlushMode.NEVER with FlushMode.MANUAL in our project, we ended up not having any actions to commit when the transaction closed, but there were still unflushed actions when the session closed. We were using a subclass of OpenSessionInView, which was allowed for configuring a different FlushMode, so this may be the source of the issue. At any rate, switching all instances of FlushMode.MANUAL back to NEVER fixed the problem.
It seems the Spring support classes should check for both.
|
|
Description
|
Hibernate 3.2 (as of CR3) has deprecated FlushMode.NEVER in favor of FlushMode.MANUAL. It seems it is purely a renaming (i.e., they have the same level of 0), but both still exist and they're distinct objects. Thus, using FlushMode.MANUAL in favor of FlushMode.NEVER will cause unexpected behavior in many hibernate-related Spring classes, which still are only checking for FlushMode.NEVER. The classes where this could be a problem include:
org.springframework.orm.hibernate3
- HibernateAccessor
- HibernateTemplate
- HibernateTransactionManager
- SessionFactoryUtils
- SpringSessionSynchronization
org.springframework.orm.hibernate3.support
- OpenSessionInViewFilter
For example, our app, which makes heavy use of both Spring and Hibernate, recently started using Spring 2.0 cr4 and Hibernate 3.2 cr4. When I replaced all occurrences of FlushMode.NEVER with FlushMode.MANUAL in our project, we ended up not having any actions to commit when the transaction closed, but there were still unflushed actions when the session closed. We were using a subclass of OpenSessionInView, which was allowed for configuring a different FlushMode, so this may be the source of the issue. At any rate, switching all instances of FlushMode.MANUAL back to NEVER fixed the problem.
It seems the Spring support classes should check for both. |
Show » |
|
Anyway, I've changed all our "equals(FlushMode.NEVER)" checks to use "FlushMode.lessThan(FlushMode.COMMIT)" instead, which should catch both NEVER and MANUAL. Furthermore, this "lessThan" check should also work on Hibernate 3.0, which we still aim to be compatible with (as far as possible; mainly for JDK 1.3 users, who won't be happy with Hibernate 3.1 and later requiring JDK 1.4+). For the latter reason, it's also that our "setFlushMode(FlushMode.NEVER)" calls have to remain the same, even if NEVER is deprecated now: "FlushMode.MANUAL" simply won't work on Hibernate 3.0/3.1. That said, this present refined code should work fine for typical needs...
Juergen