Skip to content

HibernateJpaParametersParameterAccessor constructor may throw IllegalStateException #2540

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
cigaly opened this issue May 23, 2022 · 0 comments
Assignees
Labels
status: waiting-for-triage An issue we've not yet triaged

Comments

@cigaly
Copy link
Contributor

cigaly commented May 23, 2022

When EntityManagerFactory is created with org.springframework.orm.hibernate5.LocalSessionFactoryBean,
and EntityManager is created with org.springframework.orm.jpa.SharedEntityManagerCreator.createSharedEntityManager,
and HibernateJpaParametersParameterAccessor constructor is invoked out of transaction
then java.lang.IllegalStateException is thrown with message "No transactional EntityManager available"

However, when constructor is invoked inside transaction, no exception is thrown.

Suggested patch that fixes this issue is attached.
patch.diff.txt

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label May 23, 2022
This was referenced May 23, 2022
@christophstrobl christophstrobl removed the status: waiting-for-triage An issue we've not yet triaged label May 23, 2022
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label May 23, 2022
schauder pushed a commit that referenced this issue May 25, 2022
This change avoids errors when no transactional EntityManager is available.

Closes #2540
Original pull request #2542
schauder added a commit that referenced this issue May 25, 2022
Added author tag, JavaDoc and improved test name.

See #2540
Original pull request #2542
schauder added a commit that referenced this issue May 25, 2022
Added author tag, JavaDoc and improved test name.

See #2540
Original pull request #2542
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: waiting-for-triage An issue we've not yet triaged
Projects
None yet
Development

No branches or pull requests

4 participants