Skip to content
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

Update hibernate to latest version #564

Open
yvespp opened this issue Aug 14, 2020 · 1 comment
Open

Update hibernate to latest version #564

yvespp opened this issue Aug 14, 2020 · 1 comment

Comments

@yvespp
Copy link
Member

yvespp commented Aug 14, 2020

I tried to updated hibernate but tests started to fail. Once we have updated hibernate we can also update the java ee API versions.
Ref: #563

With 5.4.20.Final multiple tests fail with this error:

[ERROR] ch.puzzle.itc.mobiliar.test.PersistingEntityBuilderTest.testAmw  Time elapsed: 0.846 s  <<< ERROR!
javax.persistence.PersistenceException:
org.hibernate.HibernateException: Illegal attempt to associate a collection with two open sessions. Collection : [ch.puzzle.itc.mobiliar.business.resourcegroup.entity.ResourceEntity.consumedMasterRelations#1]
Collection contents: [[]]
        at ch.puzzle.itc.mobiliar.test.PersistingEntityBuilderTest.testAmw(PersistingEntityBuilderTest.java:80)
Caused by: org.hibernate.HibernateException:
Illegal attempt to associate a collection with two open sessions. Collection : [ch.puzzle.itc.mobiliar.business.resourcegroup.entity.ResourceEntity.consumedMasterRelations#1]
Collection contents: [[]]
        at ch.puzzle.itc.mobiliar.test.PersistingEntityBuilderTest.testAmw(PersistingEntityBuilderTest.java:80)

With 5.3.18.Final all persistence tests fail with:

Cannot mock/spy class org.hibernate.internal.SessionImpl
Mockito cannot mock/spy because :
 - final class
        at ch.puzzle.itc.mobiliar.business.template.control.TemplatesScreenDomainServicePersistenceTest.before(TemplatesScreenDomainServicePersistenceTest.java:56)

Maybe it has to do with how we initialize the persistence context during tests?

@yvespp
Copy link
Member Author

yvespp commented Jul 16, 2021

Same with 5.5.3.Final
The session can be printed with System.out.println(entityManager);
I noticed that it changes when MockitoAnnotations.openMocks(this) is called.
The error can be provoked by calling transaction.commit() after entityManager.persist(entity). Some commits work others don't.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant