From f0f59ba71e6cb96a88028bc5f1295f8f0905dbe2 Mon Sep 17 00:00:00 2001 From: Raja Kolli Date: Wed, 25 Dec 2024 19:19:44 +0000 Subject: [PATCH] polish : Hibernate2nd level cache --- ...java => Hibernate2ndLevelCacheApplication.java} | 4 ++-- .../repositories/CustomerRepository.java | 5 +---- .../repositories/OrderItemRepository.java | 5 +---- .../repositories/OrderRepository.java | 4 +--- .../example/hibernatecache/TestApplication.java | 12 ------------ .../TestHibernate2ndLevelCacheApplication.java | 14 ++++++++++++++ 6 files changed, 19 insertions(+), 25 deletions(-) rename jpa/boot-hibernate2ndlevelcache-sample/src/main/java/com/example/hibernatecache/{Application.java => Hibernate2ndLevelCacheApplication.java} (77%) delete mode 100644 jpa/boot-hibernate2ndlevelcache-sample/src/test/java/com/example/hibernatecache/TestApplication.java create mode 100644 jpa/boot-hibernate2ndlevelcache-sample/src/test/java/com/example/hibernatecache/TestHibernate2ndLevelCacheApplication.java diff --git a/jpa/boot-hibernate2ndlevelcache-sample/src/main/java/com/example/hibernatecache/Application.java b/jpa/boot-hibernate2ndlevelcache-sample/src/main/java/com/example/hibernatecache/Hibernate2ndLevelCacheApplication.java similarity index 77% rename from jpa/boot-hibernate2ndlevelcache-sample/src/main/java/com/example/hibernatecache/Application.java rename to jpa/boot-hibernate2ndlevelcache-sample/src/main/java/com/example/hibernatecache/Hibernate2ndLevelCacheApplication.java index fe125b4d5..b4765836f 100644 --- a/jpa/boot-hibernate2ndlevelcache-sample/src/main/java/com/example/hibernatecache/Application.java +++ b/jpa/boot-hibernate2ndlevelcache-sample/src/main/java/com/example/hibernatecache/Hibernate2ndLevelCacheApplication.java @@ -7,9 +7,9 @@ @SpringBootApplication @EnableConfigurationProperties({ApplicationProperties.class}) -public class Application { +public class Hibernate2ndLevelCacheApplication { public static void main(String[] args) { - SpringApplication.run(Application.class, args); + SpringApplication.run(Hibernate2ndLevelCacheApplication.class, args); } } diff --git a/jpa/boot-hibernate2ndlevelcache-sample/src/main/java/com/example/hibernatecache/repositories/CustomerRepository.java b/jpa/boot-hibernate2ndlevelcache-sample/src/main/java/com/example/hibernatecache/repositories/CustomerRepository.java index db585b30f..c3bd90b84 100644 --- a/jpa/boot-hibernate2ndlevelcache-sample/src/main/java/com/example/hibernatecache/repositories/CustomerRepository.java +++ b/jpa/boot-hibernate2ndlevelcache-sample/src/main/java/com/example/hibernatecache/repositories/CustomerRepository.java @@ -4,7 +4,6 @@ import com.example.hibernatecache.entities.Customer; import io.hypersistence.utils.spring.repository.BaseJpaRepository; -import io.hypersistence.utils.spring.repository.HibernateRepository; import jakarta.persistence.QueryHint; import java.util.Optional; import org.springframework.data.jpa.repository.EntityGraph; @@ -15,9 +14,7 @@ import org.springframework.transaction.annotation.Transactional; public interface CustomerRepository - extends BaseJpaRepository, - HibernateRepository, - PagingAndSortingRepository { + extends BaseJpaRepository, PagingAndSortingRepository { @Transactional(readOnly = true) @QueryHints(@QueryHint(name = HINT_CACHEABLE, value = "true")) diff --git a/jpa/boot-hibernate2ndlevelcache-sample/src/main/java/com/example/hibernatecache/repositories/OrderItemRepository.java b/jpa/boot-hibernate2ndlevelcache-sample/src/main/java/com/example/hibernatecache/repositories/OrderItemRepository.java index b373bc6fe..e0df8e3e4 100644 --- a/jpa/boot-hibernate2ndlevelcache-sample/src/main/java/com/example/hibernatecache/repositories/OrderItemRepository.java +++ b/jpa/boot-hibernate2ndlevelcache-sample/src/main/java/com/example/hibernatecache/repositories/OrderItemRepository.java @@ -2,13 +2,10 @@ import com.example.hibernatecache.entities.OrderItem; import io.hypersistence.utils.spring.repository.BaseJpaRepository; -import io.hypersistence.utils.spring.repository.HibernateRepository; import org.springframework.data.repository.PagingAndSortingRepository; public interface OrderItemRepository - extends BaseJpaRepository, - HibernateRepository, - PagingAndSortingRepository { + extends BaseJpaRepository, PagingAndSortingRepository { void deleteAll(); } diff --git a/jpa/boot-hibernate2ndlevelcache-sample/src/main/java/com/example/hibernatecache/repositories/OrderRepository.java b/jpa/boot-hibernate2ndlevelcache-sample/src/main/java/com/example/hibernatecache/repositories/OrderRepository.java index 2309c0373..e98478454 100644 --- a/jpa/boot-hibernate2ndlevelcache-sample/src/main/java/com/example/hibernatecache/repositories/OrderRepository.java +++ b/jpa/boot-hibernate2ndlevelcache-sample/src/main/java/com/example/hibernatecache/repositories/OrderRepository.java @@ -2,11 +2,9 @@ import com.example.hibernatecache.entities.Order; import io.hypersistence.utils.spring.repository.BaseJpaRepository; -import io.hypersistence.utils.spring.repository.HibernateRepository; import org.springframework.data.repository.PagingAndSortingRepository; -public interface OrderRepository - extends BaseJpaRepository, HibernateRepository, PagingAndSortingRepository { +public interface OrderRepository extends BaseJpaRepository, PagingAndSortingRepository { void deleteAll(); } diff --git a/jpa/boot-hibernate2ndlevelcache-sample/src/test/java/com/example/hibernatecache/TestApplication.java b/jpa/boot-hibernate2ndlevelcache-sample/src/test/java/com/example/hibernatecache/TestApplication.java deleted file mode 100644 index 852175b39..000000000 --- a/jpa/boot-hibernate2ndlevelcache-sample/src/test/java/com/example/hibernatecache/TestApplication.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.example.hibernatecache; - -import com.example.hibernatecache.common.ContainersConfig; -import org.springframework.boot.SpringApplication; - -public class TestApplication { - - public static void main(String[] args) { - System.setProperty("spring.profiles.active", "local"); - SpringApplication.from(Application::main).with(ContainersConfig.class).run(args); - } -} diff --git a/jpa/boot-hibernate2ndlevelcache-sample/src/test/java/com/example/hibernatecache/TestHibernate2ndLevelCacheApplication.java b/jpa/boot-hibernate2ndlevelcache-sample/src/test/java/com/example/hibernatecache/TestHibernate2ndLevelCacheApplication.java new file mode 100644 index 000000000..4702dab5c --- /dev/null +++ b/jpa/boot-hibernate2ndlevelcache-sample/src/test/java/com/example/hibernatecache/TestHibernate2ndLevelCacheApplication.java @@ -0,0 +1,14 @@ +package com.example.hibernatecache; + +import com.example.hibernatecache.common.ContainersConfig; +import org.springframework.boot.SpringApplication; + +public class TestHibernate2ndLevelCacheApplication { + + public static void main(String[] args) { + SpringApplication.from(Hibernate2ndLevelCacheApplication::main) + .with(ContainersConfig.class) + .withAdditionalProfiles("local") + .run(args); + } +}