From 237f8ef944d8ac34e71ad2eb0c6280b4c6609072 Mon Sep 17 00:00:00 2001 From: Loredana Crusoveanu Date: Sun, 16 Sep 2018 19:56:05 +0300 Subject: [PATCH] fix spring-jpa start --- .../java/org/baeldung/config/PersistenceJPAConfig.java | 6 +++--- .../src/main/java/org/baeldung/config/WebInitializer.java | 2 +- .../{criteria/repository => dao}/BookRepository.java | 4 ++-- .../repository => dao}/BookRepositoryCustom.java | 4 ++-- .../{criteria => }/dao/BookRepositoryImpl.java | 5 ++--- .../{criteria/repository => dao}/BookService.java | 8 ++++---- .../{criteria/repository => dao}/BookSpecifications.java | 4 ++-- .../baeldung/persistence/{criteria => }/model/Book.java | 2 +- .../spring-jpa/src/main/resources/persistence.xml | 2 -- 9 files changed, 17 insertions(+), 20 deletions(-) rename persistence-modules/spring-jpa/src/main/java/org/baeldung/persistence/{criteria/repository => dao}/BookRepository.java (71%) rename persistence-modules/spring-jpa/src/main/java/org/baeldung/persistence/{criteria/repository => dao}/BookRepositoryCustom.java (58%) rename persistence-modules/spring-jpa/src/main/java/org/baeldung/persistence/{criteria => }/dao/BookRepositoryImpl.java (87%) rename persistence-modules/spring-jpa/src/main/java/org/baeldung/persistence/{criteria/repository => dao}/BookService.java (63%) rename persistence-modules/spring-jpa/src/main/java/org/baeldung/persistence/{criteria/repository => dao}/BookSpecifications.java (78%) rename persistence-modules/spring-jpa/src/main/java/org/baeldung/persistence/{criteria => }/model/Book.java (91%) diff --git a/persistence-modules/spring-jpa/src/main/java/org/baeldung/config/PersistenceJPAConfig.java b/persistence-modules/spring-jpa/src/main/java/org/baeldung/config/PersistenceJPAConfig.java index 78c4116c67..ec0d4bca3c 100644 --- a/persistence-modules/spring-jpa/src/main/java/org/baeldung/config/PersistenceJPAConfig.java +++ b/persistence-modules/spring-jpa/src/main/java/org/baeldung/config/PersistenceJPAConfig.java @@ -78,9 +78,9 @@ public class PersistenceJPAConfig { final Properties hibernateProperties = new Properties(); hibernateProperties.setProperty("hibernate.hbm2ddl.auto", env.getProperty("hibernate.hbm2ddl.auto")); hibernateProperties.setProperty("hibernate.dialect", env.getProperty("hibernate.dialect")); - hibernateProperties.setProperty("hibernate.cache.use_second_level_cache", env.getProperty("hibernate.cache.use_second_level_cache")); - hibernateProperties.setProperty("hibernate.cache.use_query_cache", env.getProperty("hibernate.cache.use_query_cache")); - // hibernateProperties.setProperty("hibernate.globally_quoted_identifiers", "true"); + hibernateProperties.setProperty("hibernate.cache.use_second_level_cache", "false"); + + return hibernateProperties; } diff --git a/persistence-modules/spring-jpa/src/main/java/org/baeldung/config/WebInitializer.java b/persistence-modules/spring-jpa/src/main/java/org/baeldung/config/WebInitializer.java index 1c8ce5400f..cf6e69eb39 100644 --- a/persistence-modules/spring-jpa/src/main/java/org/baeldung/config/WebInitializer.java +++ b/persistence-modules/spring-jpa/src/main/java/org/baeldung/config/WebInitializer.java @@ -5,7 +5,7 @@ import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatche public class WebInitializer extends AbstractAnnotationConfigDispatcherServletInitializer { @Override protected Class[] getRootConfigClasses() { - return new Class[] { PersistenceJNDIConfig.class }; + return new Class[] { PersistenceJPAConfig.class }; } @Override diff --git a/persistence-modules/spring-jpa/src/main/java/org/baeldung/persistence/criteria/repository/BookRepository.java b/persistence-modules/spring-jpa/src/main/java/org/baeldung/persistence/dao/BookRepository.java similarity index 71% rename from persistence-modules/spring-jpa/src/main/java/org/baeldung/persistence/criteria/repository/BookRepository.java rename to persistence-modules/spring-jpa/src/main/java/org/baeldung/persistence/dao/BookRepository.java index af30ae461e..114cf48c7c 100644 --- a/persistence-modules/spring-jpa/src/main/java/org/baeldung/persistence/criteria/repository/BookRepository.java +++ b/persistence-modules/spring-jpa/src/main/java/org/baeldung/persistence/dao/BookRepository.java @@ -1,6 +1,6 @@ -package org.baeldung.persistence.criteria.repository; +package org.baeldung.persistence.dao; -import org.baeldung.persistence.criteria.model.Book; +import org.baeldung.persistence.model.Book; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaSpecificationExecutor; diff --git a/persistence-modules/spring-jpa/src/main/java/org/baeldung/persistence/criteria/repository/BookRepositoryCustom.java b/persistence-modules/spring-jpa/src/main/java/org/baeldung/persistence/dao/BookRepositoryCustom.java similarity index 58% rename from persistence-modules/spring-jpa/src/main/java/org/baeldung/persistence/criteria/repository/BookRepositoryCustom.java rename to persistence-modules/spring-jpa/src/main/java/org/baeldung/persistence/dao/BookRepositoryCustom.java index 35330cfa3c..b939907572 100644 --- a/persistence-modules/spring-jpa/src/main/java/org/baeldung/persistence/criteria/repository/BookRepositoryCustom.java +++ b/persistence-modules/spring-jpa/src/main/java/org/baeldung/persistence/dao/BookRepositoryCustom.java @@ -1,8 +1,8 @@ -package org.baeldung.persistence.criteria.repository; +package org.baeldung.persistence.dao; import java.util.List; -import org.baeldung.persistence.criteria.model.Book; +import org.baeldung.persistence.model.Book; public interface BookRepositoryCustom { diff --git a/persistence-modules/spring-jpa/src/main/java/org/baeldung/persistence/criteria/dao/BookRepositoryImpl.java b/persistence-modules/spring-jpa/src/main/java/org/baeldung/persistence/dao/BookRepositoryImpl.java similarity index 87% rename from persistence-modules/spring-jpa/src/main/java/org/baeldung/persistence/criteria/dao/BookRepositoryImpl.java rename to persistence-modules/spring-jpa/src/main/java/org/baeldung/persistence/dao/BookRepositoryImpl.java index f782d69e1e..6e9aa998d7 100644 --- a/persistence-modules/spring-jpa/src/main/java/org/baeldung/persistence/criteria/dao/BookRepositoryImpl.java +++ b/persistence-modules/spring-jpa/src/main/java/org/baeldung/persistence/dao/BookRepositoryImpl.java @@ -1,4 +1,4 @@ -package org.baeldung.persistence.criteria.dao; +package org.baeldung.persistence.dao; import java.util.ArrayList; import java.util.List; @@ -10,8 +10,7 @@ import javax.persistence.criteria.CriteriaQuery; import javax.persistence.criteria.Predicate; import javax.persistence.criteria.Root; -import org.baeldung.persistence.criteria.model.Book; -import org.baeldung.persistence.criteria.repository.BookRepositoryCustom; +import org.baeldung.persistence.model.Book; import org.springframework.stereotype.Repository; @Repository diff --git a/persistence-modules/spring-jpa/src/main/java/org/baeldung/persistence/criteria/repository/BookService.java b/persistence-modules/spring-jpa/src/main/java/org/baeldung/persistence/dao/BookService.java similarity index 63% rename from persistence-modules/spring-jpa/src/main/java/org/baeldung/persistence/criteria/repository/BookService.java rename to persistence-modules/spring-jpa/src/main/java/org/baeldung/persistence/dao/BookService.java index 7b1aff857e..88b769e9bf 100644 --- a/persistence-modules/spring-jpa/src/main/java/org/baeldung/persistence/criteria/repository/BookService.java +++ b/persistence-modules/spring-jpa/src/main/java/org/baeldung/persistence/dao/BookService.java @@ -1,12 +1,12 @@ -package org.baeldung.persistence.criteria.repository; +package org.baeldung.persistence.dao; -import static org.baeldung.persistence.criteria.repository.BookSpecifications.hasAuthor; -import static org.baeldung.persistence.criteria.repository.BookSpecifications.titleContains; +import static org.baeldung.persistence.dao.BookSpecifications.hasAuthor; +import static org.baeldung.persistence.dao.BookSpecifications.titleContains; import static org.springframework.data.jpa.domain.Specifications.where; import java.util.List; -import org.baeldung.persistence.criteria.model.Book; +import org.baeldung.persistence.model.Book; import org.springframework.stereotype.Service; @Service diff --git a/persistence-modules/spring-jpa/src/main/java/org/baeldung/persistence/criteria/repository/BookSpecifications.java b/persistence-modules/spring-jpa/src/main/java/org/baeldung/persistence/dao/BookSpecifications.java similarity index 78% rename from persistence-modules/spring-jpa/src/main/java/org/baeldung/persistence/criteria/repository/BookSpecifications.java rename to persistence-modules/spring-jpa/src/main/java/org/baeldung/persistence/dao/BookSpecifications.java index 392b750977..ed9540060d 100644 --- a/persistence-modules/spring-jpa/src/main/java/org/baeldung/persistence/criteria/repository/BookSpecifications.java +++ b/persistence-modules/spring-jpa/src/main/java/org/baeldung/persistence/dao/BookSpecifications.java @@ -1,6 +1,6 @@ -package org.baeldung.persistence.criteria.repository; +package org.baeldung.persistence.dao; -import org.baeldung.persistence.criteria.model.Book; +import org.baeldung.persistence.model.Book; import org.springframework.data.jpa.domain.Specification; public class BookSpecifications { diff --git a/persistence-modules/spring-jpa/src/main/java/org/baeldung/persistence/criteria/model/Book.java b/persistence-modules/spring-jpa/src/main/java/org/baeldung/persistence/model/Book.java similarity index 91% rename from persistence-modules/spring-jpa/src/main/java/org/baeldung/persistence/criteria/model/Book.java rename to persistence-modules/spring-jpa/src/main/java/org/baeldung/persistence/model/Book.java index beb6c0190c..754bd179d1 100644 --- a/persistence-modules/spring-jpa/src/main/java/org/baeldung/persistence/criteria/model/Book.java +++ b/persistence-modules/spring-jpa/src/main/java/org/baeldung/persistence/model/Book.java @@ -1,4 +1,4 @@ -package org.baeldung.persistence.criteria.model; +package org.baeldung.persistence.model; import javax.persistence.Entity; import javax.persistence.Id; diff --git a/persistence-modules/spring-jpa/src/main/resources/persistence.xml b/persistence-modules/spring-jpa/src/main/resources/persistence.xml index 65bad29cdc..6304fa0a65 100644 --- a/persistence-modules/spring-jpa/src/main/resources/persistence.xml +++ b/persistence-modules/spring-jpa/src/main/resources/persistence.xml @@ -21,8 +21,6 @@ ${hibernate.hbm2ddl.auto} ${hibernate.dialect} - ${hibernate.cache.use_second_level_cache} - ${hibernate.cache.use_query_cache}