Issue Type: Improvement Improvement
Affects Versions: 4.2.0.Final, 4.1.1.Final, 4.1.0.Final, 4.0.0.Final
Assignee: Unassigned
Components: engine
Created: 05/Feb/13 3:19 AM
Description:

I have a use-case with a nested transaction in a loop.

When the nested transaction is committed, I manually flush and clear the Hibernate-Session, because otherwise, the program would run into an OutOfMemoryException, because it loads to many objects into the Hibernate-Session.

Sometimes, the nested transaction is rolled back, to cancel some work, because of invalid data or other errors. In this case I have to clear the Hibernate-Session, so that the modified objects are not saved by Hibernate.

When the nested transaction is committed and I am flushing the HibernateSession, I can flush the FullTextSession accordingly via FullTextSession.flushToIndexes().

But, when the nested transaction has to be rolled back, I am not able to cancel the work recorded by the FullTextSession. FullTextSession.clear() has no effect on the queued work. This leads to errors: because I have flushed the Hibernate-Session manually, the queued work sometimes is causing LazyInitializationException's. And: it should not be written to the index, because I have thrown away the modified objects and the index would get out of sync, if the queued work is not canceled.

I searched the documentation and the internet for hours, but I can't find any way, to cancel work.

I think it would be reasonable, to overwrite Session.clear() in FullTextSession and cancel all queued work, like when the session is rolled back. Because, this is, what a user expects, when he clears the FullTextSession.
Another possibility would be, to implement a Method like FullTextSession.clearQueuedWork() or .cancelWork().

Environment: Spring 3.2 + Hibernate 4.1.8.Final
Project: Hibernate Search
Priority: Major Major
Reporter: Kai Moritz
Original Estimate: 1h
Remaining Estimate: 1h
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira