HHH000260: Exception calling user Synchronization [org.hibernate.search.backend.impl.EventSourceTransactionContext$BeforeCommitSynchronizationDelegator@b4884752] : org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: com.myapp.loan.LoanApplication.subloans, could not initialize proxy - the owning Session was closed>
Caused by: org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: com.myapp.entities.LoanApplication.subloans, could not initialize proxy - the owning Session was closed
Below is the code line causing this issue.
org.hibernate.search.jpa.FullTextEntityManager fullTextEntityManager = org.hibernate.search.jpa.Search
.getFullTextEntityManager(entityManager);
fullTextEntityManager.index(loanApplication);
Session is marked as closed which doesn't allow the entity to update the indexes. Please see the attached testcase.
Below is the link to pull request.
https://github.com/hibernate/hibernate-orm/pull/1969
Update AbstractLazyInitializer.java to fix below issue for setting index from search in version hibernate-core 5.2.8
// Old Code
if ( session.isClosed() ) {
throw new SessionException(
"Session is closed. The read-only/modifiable setting is only accessible when the proxy is associated with an open session."
);
}
// Updated Code
if ( !session.isOpenOrWaitingForAutoClose() ) {
throw new SessionException(
"Session is closed. The read-only/modifiable setting is only accessible when the proxy is associated with an open session."
);
}
I verified this and indeed it was failing in Hibernate ORM 5.2.8.Final but it no longer fails when I upgrade to 5.2.12.Final.
I recommend you upgrade. Thanks again for the report!
Hello,
Would it be possible for you to back port these changes to 5.2.8.Final?
Would it be possible for you to back port these changes to 5.2.8.Final?
Do you mean release a version 5.2.8-2 for Hibernate ORM with a fix for this specific issue? That's very unlikely to happen. We only have three levels in our versioning scheme, though some vendors such as Red Hat may add a level of their own to backport fixes for their customers.
I don't see the point though: if you are willing to upgrade to a (hypothetical) 5.2.8-2, could you not just upgrade to 5.2.12.Final or later?
, , can this be resolved as Out of Date?
done. Thanks!