-
Sep 16th, 2011, 10:51 AM
#1
Keep Session open for TaskExecutor
I have a Spring Controller that needs to deliver several email notifications as a side effect to persisting a domain entity. The emails are formed and delivered in a background thread via autowired TaskExecutor for a speedy user experience, but the problem is that Spring closes my Hibernate session as soon as the resulting View is finished rendering (while the background task is still using it). Obviously, this is causing lazy initialization exceptions.
Is there a way to keep a Spring-managed Hibernate session open for the duration of background threads launched using TaskExecutor?
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules