Skip to content

Add callback for Hibernate StatelessSession to HibernateTemplate [SPR-6202] #10870

@spring-projects-issues

Description

@spring-projects-issues

Andrew Goode opened SPR-6202 and commented

Add a new StatelessHibernateCallback interface with generic execution logic added to HibernateTemplate.

I have implemented similar functionality in my current project and have found that it's very useful for performing batch operations via Hibernate, especially when executing in threads outside the context of a Spring AOP-managed transaction. According to #7184 and related forum posts, direct support for StatelessSessions seems to be a popular request. This enhancement could be the first step to providing that support with Spring out-of-the-box.

The provided patch introduces the implementation used on my project in a form useful to others, including simple unit test. Admittedly, this proposed implementation may not be robust enough to satisfy all use cases, but it should serve as at least a good starting point. Will need to consider the implications of exposing thread-bound JDBC Connections and relying on implementation of SessionFactoryUtils#getDataSource(SessionFactory). Please see patch for details.


Affects: 3.0 RC1

Attachments:

Issue Links:

4 votes, 6 watchers

Metadata

Metadata

Assignees

Labels

in: dataIssues in data modules (jdbc, orm, oxm, tx)status: declinedA suggestion or change that we don't feel we should currently applytype: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions