diff --git a/spring-boot-modules/spring-boot-3/src/main/java/com/baeldung/recordswithjpa/entity/Book.java b/spring-boot-modules/spring-boot-3/src/main/java/com/baeldung/recordswithjpa/entity/Book.java index 6fc43e516564..9ea982e32376 100644 --- a/spring-boot-modules/spring-boot-3/src/main/java/com/baeldung/recordswithjpa/entity/Book.java +++ b/spring-boot-modules/spring-boot-3/src/main/java/com/baeldung/recordswithjpa/entity/Book.java @@ -67,16 +67,4 @@ public void setIsbn(String isbn) { this.isbn = isbn; } - - @Version - private Long version; - - public Long getVersion() { - return version; - } - - public void setVersion(Long version) { - this.version = version; - } - } \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-3/src/test/java/com/baeldung/recordswithjpa/QueryServiceIntegrationTest.java b/spring-boot-modules/spring-boot-3/src/test/java/com/baeldung/recordswithjpa/QueryServiceIntegrationTest.java index 7e1ffd2ec5c2..09c680554490 100644 --- a/spring-boot-modules/spring-boot-3/src/test/java/com/baeldung/recordswithjpa/QueryServiceIntegrationTest.java +++ b/spring-boot-modules/spring-boot-3/src/test/java/com/baeldung/recordswithjpa/QueryServiceIntegrationTest.java @@ -3,13 +3,11 @@ import com.baeldung.recordswithjpa.records.BookRecord; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.annotation.DirtiesContext; import java.util.List; import static org.junit.jupiter.api.Assertions.*; -@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD) public class QueryServiceIntegrationTest extends RecordsAsJpaIntegrationTest { @Autowired diff --git a/spring-boot-modules/spring-boot-3/src/test/java/com/baeldung/recordswithjpa/RecordsAsJpaIntegrationTest.java b/spring-boot-modules/spring-boot-3/src/test/java/com/baeldung/recordswithjpa/RecordsAsJpaIntegrationTest.java index 18e9f19016db..4268bd58bb10 100644 --- a/spring-boot-modules/spring-boot-3/src/test/java/com/baeldung/recordswithjpa/RecordsAsJpaIntegrationTest.java +++ b/spring-boot-modules/spring-boot-3/src/test/java/com/baeldung/recordswithjpa/RecordsAsJpaIntegrationTest.java @@ -2,8 +2,10 @@ import com.baeldung.recordswithjpa.entity.Book; import com.baeldung.recordswithjpa.repository.BookRepository; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; + +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.TestInstance; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; @@ -11,11 +13,12 @@ @Transactional @SpringBootTest +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class RecordsAsJpaIntegrationTest { @Autowired protected BookRepository bookRepository; - @BeforeEach + @BeforeAll void setUp() { Book book = new Book(null,"The Lord of the Rings", "J.R.R. Tolkien", "978-0544003415"); @@ -28,7 +31,7 @@ void setUp() { bookRepository.save(book3); } - @AfterEach + @AfterAll void tearDown() { bookRepository.deleteAll(); } diff --git a/spring-boot-modules/spring-boot-3/src/test/java/com/baeldung/recordswithjpa/repository/BookRepositoryIntegrationTest.java b/spring-boot-modules/spring-boot-3/src/test/java/com/baeldung/recordswithjpa/repository/BookRepositoryIntegrationTest.java index 442cdbb5243b..9173fea269ff 100644 --- a/spring-boot-modules/spring-boot-3/src/test/java/com/baeldung/recordswithjpa/repository/BookRepositoryIntegrationTest.java +++ b/spring-boot-modules/spring-boot-3/src/test/java/com/baeldung/recordswithjpa/repository/BookRepositoryIntegrationTest.java @@ -2,11 +2,9 @@ import com.baeldung.recordswithjpa.RecordsAsJpaIntegrationTest; import org.junit.jupiter.api.Test; -import org.springframework.test.annotation.DirtiesContext; import static org.junit.jupiter.api.Assertions.*; -@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD) class BookRepositoryIntegrationTest extends RecordsAsJpaIntegrationTest { @Test