I am migrating Spring Boot application from version 2.7 to version 3.0. After modifications made in pom.xml, big part of my unit tests in Groovy classes started to fail. In some cases, there were issues with application context, and in the other ones – assertion errors. I managed to fix most of them except two UTs, when there is an assertion checking the size of orders collection:
orders.findAll().size() == 1
expected: 1, actual: 2
Unfortunately, I cannot show much of the code to illustrate the problem, but the general steps of the process is a simple scenario:
- Given – order is created in database
- When – order is cancelled and replaced by new version (+1) of same order, with same data
- Then – the size of collection should show that there is only one active order in collection, we expect to see that collection size will be equal to 1, not 2
There were no changes in business logic. It seems that maybe something has changed in orm-related dependencies which causes that issue?
ORM dependencies in pom.xml which has changed:
BEFORE:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.18</version>
<relativePath/>
</parent>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>1.4.200</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-jcache</artifactId>
</dependency>
<dependency>
<groupId>org.hibernate.orm</groupId>
<artifactId>hibernate-envers</artifactId>
</dependency>
<dependency>
<groupId>org.hibernate.orm</groupId>
<artifactId>hibernate-core</artifactId>
</dependency>
<dependency>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.1-api</artifactId>
<version>1.0.0.Final</version>
</dependency>
AFTER:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.0.0</version>
<relativePath/>
</parent>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
<version>3.1.0</version>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>2.1.214</version>
</dependency>
<dependency>
<groupId>org.hibernate.orm</groupId>
<artifactId>hibernate-jcache</artifactId>
<version>6.1.7.Final</version>
</dependency>
<dependency>
<groupId>jakarta.jms</groupId>
<artifactId>jakarta.jms-api</artifactId>
<version>3.1.0</version>
</dependency>
I checked if cleanup() method works correctly in test class but it seems that it is ok as well.
Did anyone have similar issue with Hibernate and DB-connected changes?
2