-
Notifications
You must be signed in to change notification settings - Fork 38.7k
Description
Jon Seymour opened SPR-3204 and commented
Trivial subclasses of HibernateDaoSupport will normally be thread-safe without explicit programmer effort. However, this relies on the assumption that DAO methods do not modify the HibernateTemplate object returned by HibernateDaoSupport.getHibernateTemplate().
However, a common programming task is to implement finder methods which limit the size of the returned result set. The obvious way to do this is to call the setMaxResults() method on the HibernateTemplate returned by getHibernateTemplate().
Unfortunately, this introduces a thread-safety issue unless precautions are taken to prevent concurrent access to the HibernateTemplate returned from getHibernateTemplate(). Even in the absence of concurrency, a failure by the programmer to restore the original value of setMaxResults() can cause other methods on the same HibernateDaoSupport instance to malfunction due to incorrectly set limits.
It might be helpful if the javadoc for HibernateDaoSupport.getHibernateTemplate() reminded the reader that the returned object should not be modified unless the caller fully understands all the implications of doing so.
Affects: 1.2.8, 2.0.2
Backported to: 1.2.9
1 votes, 0 watchers