Spring Boot

This is a note for Spring Boot

Issues


org.springframework.dao.InvalidDataAccessApiUsageException: No EntityManager with actual transaction available for current thread - cannot reliably process ‘remove’ call; nested exception is javax.persistence.TransactionRequiredException: No EntityManager with actual transaction available for current thread - cannot reliably process ‘remove’ call

Solution:

  • Add @Transactional to deleteByXXXIn()

  • OnDelete(action = OnDeleteAction.CASCADE) Put on child property to enable removing parent cascade to current

  • Delete clause should be after find clause to make entity managed by transaction.


org.springframework.dao.InvalidDataAccessApiUsageException: org.hibernate.loader.MultipleBagFetchException: cannot simultaneously fetch multiple bags: [model.project.FProjectRequest.languageInfoList, model.project.FProjectRequest.certificateInfoList]; nested exception is java.lang.IllegalArgumentException: org.hibernate.loader.MultipleBagFetchException: cannot simultaneously fetch multiple bags: [model.project.FProjectRequest.languageInfoList, model.project.FProjectRequest.certificateInfoList]

Solution: Use @OrderColumn on List properties

comments powered by Disqus
Built with Hugo
Theme Stack designed by Jimmy