From d8bfa4af436719ca98da73c8f7ff8c28cdc6cc9a Mon Sep 17 00:00:00 2001 From: Krzysiek Date: Mon, 10 Aug 2020 21:55:24 +0200 Subject: [PATCH 1/2] JAVA-2305: Move Use Criteria Queries in a Spring Data Application to spring-data-jpa-query-2 --- .../spring-data-jpa-query-2/README.md | 16 +++++++++ .../spring-data-jpa-query-2/pom.xml | 33 +++++++++++++++++++ .../persistence/dao/BookRepository.java | 0 .../persistence/dao/BookRepositoryCustom.java | 4 +-- .../persistence/dao/BookRepositoryImpl.java | 9 +++-- .../baeldung/persistence/dao/BookService.java | 12 +++---- .../persistence/dao/BookSpecifications.java | 0 .../com/baeldung/persistence/model/Book.java | 0 .../spring-data-jpa-query/README.md | 1 + persistence-modules/spring-jpa/README.md | 1 - 10 files changed, 62 insertions(+), 14 deletions(-) create mode 100644 persistence-modules/spring-data-jpa-query-2/README.md create mode 100644 persistence-modules/spring-data-jpa-query-2/pom.xml rename persistence-modules/{spring-jpa => spring-data-jpa-query-2}/src/main/java/com/baeldung/persistence/dao/BookRepository.java (100%) rename persistence-modules/{spring-jpa => spring-data-jpa-query-2}/src/main/java/com/baeldung/persistence/dao/BookRepositoryCustom.java (100%) rename persistence-modules/{spring-jpa => spring-data-jpa-query-2}/src/main/java/com/baeldung/persistence/dao/BookRepositoryImpl.java (99%) rename persistence-modules/{spring-jpa => spring-data-jpa-query-2}/src/main/java/com/baeldung/persistence/dao/BookService.java (90%) rename persistence-modules/{spring-jpa => spring-data-jpa-query-2}/src/main/java/com/baeldung/persistence/dao/BookSpecifications.java (100%) rename persistence-modules/{spring-jpa => spring-data-jpa-query-2}/src/main/java/com/baeldung/persistence/model/Book.java (100%) diff --git a/persistence-modules/spring-data-jpa-query-2/README.md b/persistence-modules/spring-data-jpa-query-2/README.md new file mode 100644 index 0000000000..a4d657d4c6 --- /dev/null +++ b/persistence-modules/spring-data-jpa-query-2/README.md @@ -0,0 +1,16 @@ +## Spring Data JPA - Query + +This module contains articles about querying data using Spring Data JPA + +### Relevant Articles: +- [Use Criteria Queries in a Spring Data Application](https://www.baeldung.com/spring-data-criteria-queries) +- More articles: [[<-- prev]](../spring-data-jpa-query) + +### Eclipse Config +After importing the project into Eclipse, you may see the following error: +"No persistence xml file found in project" + +This can be ignored: +- Project -> Properties -> Java Persistance -> JPA -> Error/Warnings -> Select Ignore on "No persistence xml file found in project" +Or: +- Eclipse -> Preferences - Validation - disable the "Build" execution of the JPA Validator diff --git a/persistence-modules/spring-data-jpa-query-2/pom.xml b/persistence-modules/spring-data-jpa-query-2/pom.xml new file mode 100644 index 0000000000..b9e5120543 --- /dev/null +++ b/persistence-modules/spring-data-jpa-query-2/pom.xml @@ -0,0 +1,33 @@ + + + 4.0.0 + spring-data-jpa-query + spring-data-jpa-query-2 + + + com.baeldung + parent-boot-2 + 0.0.1-SNAPSHOT + ../../parent-boot-2 + + + + + org.springframework.boot + spring-boot-starter-data-jpa + + + + com.h2database + h2 + + + + com.fasterxml.jackson.core + jackson-databind + + + + \ No newline at end of file diff --git a/persistence-modules/spring-jpa/src/main/java/com/baeldung/persistence/dao/BookRepository.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/BookRepository.java similarity index 100% rename from persistence-modules/spring-jpa/src/main/java/com/baeldung/persistence/dao/BookRepository.java rename to persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/BookRepository.java diff --git a/persistence-modules/spring-jpa/src/main/java/com/baeldung/persistence/dao/BookRepositoryCustom.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/BookRepositoryCustom.java similarity index 100% rename from persistence-modules/spring-jpa/src/main/java/com/baeldung/persistence/dao/BookRepositoryCustom.java rename to persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/BookRepositoryCustom.java index 1b46d0ecc3..eda34542df 100644 --- a/persistence-modules/spring-jpa/src/main/java/com/baeldung/persistence/dao/BookRepositoryCustom.java +++ b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/BookRepositoryCustom.java @@ -1,9 +1,9 @@ package com.baeldung.persistence.dao; -import java.util.List; - import com.baeldung.persistence.model.Book; +import java.util.List; + public interface BookRepositoryCustom { List findBooksByAuthorNameAndTitle(String authorName, String title); diff --git a/persistence-modules/spring-jpa/src/main/java/com/baeldung/persistence/dao/BookRepositoryImpl.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/BookRepositoryImpl.java similarity index 99% rename from persistence-modules/spring-jpa/src/main/java/com/baeldung/persistence/dao/BookRepositoryImpl.java rename to persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/BookRepositoryImpl.java index 241a4c05aa..7f5bedd018 100644 --- a/persistence-modules/spring-jpa/src/main/java/com/baeldung/persistence/dao/BookRepositoryImpl.java +++ b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/BookRepositoryImpl.java @@ -1,7 +1,7 @@ package com.baeldung.persistence.dao; -import java.util.ArrayList; -import java.util.List; +import com.baeldung.persistence.model.Book; +import org.springframework.stereotype.Repository; import javax.persistence.EntityManager; import javax.persistence.TypedQuery; @@ -9,9 +9,8 @@ import javax.persistence.criteria.CriteriaBuilder; import javax.persistence.criteria.CriteriaQuery; import javax.persistence.criteria.Predicate; import javax.persistence.criteria.Root; - -import com.baeldung.persistence.model.Book; -import org.springframework.stereotype.Repository; +import java.util.ArrayList; +import java.util.List; @Repository public class BookRepositoryImpl implements BookRepositoryCustom { diff --git a/persistence-modules/spring-jpa/src/main/java/com/baeldung/persistence/dao/BookService.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/BookService.java similarity index 90% rename from persistence-modules/spring-jpa/src/main/java/com/baeldung/persistence/dao/BookService.java rename to persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/BookService.java index f02f9daa11..4165cd8eb9 100644 --- a/persistence-modules/spring-jpa/src/main/java/com/baeldung/persistence/dao/BookService.java +++ b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/BookService.java @@ -1,14 +1,14 @@ package com.baeldung.persistence.dao; -import static com.baeldung.persistence.dao.BookSpecifications.hasAuthor; -import static com.baeldung.persistence.dao.BookSpecifications.titleContains; -import static org.springframework.data.jpa.domain.Specifications.where; - -import java.util.List; - import com.baeldung.persistence.model.Book; import org.springframework.stereotype.Service; +import java.util.List; + +import static com.baeldung.persistence.dao.BookSpecifications.hasAuthor; +import static com.baeldung.persistence.dao.BookSpecifications.titleContains; +import static org.springframework.data.jpa.domain.Specification.where; + @Service public class BookService { diff --git a/persistence-modules/spring-jpa/src/main/java/com/baeldung/persistence/dao/BookSpecifications.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/BookSpecifications.java similarity index 100% rename from persistence-modules/spring-jpa/src/main/java/com/baeldung/persistence/dao/BookSpecifications.java rename to persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/dao/BookSpecifications.java diff --git a/persistence-modules/spring-jpa/src/main/java/com/baeldung/persistence/model/Book.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/model/Book.java similarity index 100% rename from persistence-modules/spring-jpa/src/main/java/com/baeldung/persistence/model/Book.java rename to persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/persistence/model/Book.java diff --git a/persistence-modules/spring-data-jpa-query/README.md b/persistence-modules/spring-data-jpa-query/README.md index bfff3c0ef3..34e397394b 100644 --- a/persistence-modules/spring-data-jpa-query/README.md +++ b/persistence-modules/spring-data-jpa-query/README.md @@ -11,6 +11,7 @@ This module contains articles about querying data using Spring Data JPA - [Spring Data JPA Query by Example](https://www.baeldung.com/spring-data-query-by-example) - [JPA Join Types](https://www.baeldung.com/jpa-join-types) - [Spring Data JPA and Named Entity Graphs](https://www.baeldung.com/spring-data-jpa-named-entity-graphs) +- More articles: [[more -->]](../spring-data-jpa-query-2) ### Eclipse Config After importing the project into Eclipse, you may see the following error: diff --git a/persistence-modules/spring-jpa/README.md b/persistence-modules/spring-jpa/README.md index 94a1e1f575..cd7e090e09 100644 --- a/persistence-modules/spring-jpa/README.md +++ b/persistence-modules/spring-jpa/README.md @@ -10,7 +10,6 @@ - [Self-Contained Testing Using an In-Memory Database](https://www.baeldung.com/spring-jpa-test-in-memory-database) - [A Guide to Spring AbstractRoutingDatasource](https://www.baeldung.com/spring-abstract-routing-data-source) - [Obtaining Auto-generated Keys in Spring JDBC](https://www.baeldung.com/spring-jdbc-autogenerated-keys) -- [Use Criteria Queries in a Spring Data Application](https://www.baeldung.com/spring-data-criteria-queries) - [Many-To-Many Relationship in JPA](https://www.baeldung.com/jpa-many-to-many) - [Spring Persistence (Hibernate and JPA) with a JNDI datasource](https://www.baeldung.com/spring-persistence-hibernate-and-jpa-with-a-jndi-datasource-2) From 1acfa2eabf78228d81bd84dd9d947eb739a28224 Mon Sep 17 00:00:00 2001 From: Krzysztof Woyke Date: Wed, 19 Aug 2020 10:26:34 +0200 Subject: [PATCH 2/2] JAVA-2305: Fix merge --- .../com/baeldung/spring/session/SessionConfig.java | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 spring-session/spring-session-redis/src/main/java/com/baeldung/spring/session/SessionConfig.java diff --git a/spring-session/spring-session-redis/src/main/java/com/baeldung/spring/session/SessionConfig.java b/spring-session/spring-session-redis/src/main/java/com/baeldung/spring/session/SessionConfig.java new file mode 100644 index 0000000000..5a9bc9ff28 --- /dev/null +++ b/spring-session/spring-session-redis/src/main/java/com/baeldung/spring/session/SessionConfig.java @@ -0,0 +1,10 @@ +package com.baeldung.spring.session; + +import org.springframework.context.annotation.Configuration; +import org.springframework.session.data.redis.config.annotation.web.http.EnableRedisHttpSession; +import org.springframework.session.web.context.AbstractHttpSessionApplicationInitializer; + +@Configuration +@EnableRedisHttpSession +public class SessionConfig extends AbstractHttpSessionApplicationInitializer { +}