From 17449fa3de785d4a35777e6105305a077091bad6 Mon Sep 17 00:00:00 2001 From: Haroon Khan Date: Tue, 11 Jan 2022 08:43:33 +0000 Subject: [PATCH] [JAVA-8369] Split spring-data-jpa-query-2 module --- persistence-modules/pom.xml | 1 + .../spring-data-jpa-query-2/README.md | 9 +++--- .../spring-data-jpa-query-3/README.md | 16 ++++++++++ .../spring-data-jpa-query-3/pom.xml | 32 +++++++++++++++++++ .../data/jpa/query/QueryApplication.java | 13 ++++++++ .../data/jpa/query/datetime/Article.java | 3 ++ .../jpa/query/datetime/ArticleRepository.java | 0 .../src/main/resources/application.properties | 1 + .../src/main/resources/import_entities.sql | 0 .../src/main/resources/logback.xml | 19 +++++++++++ .../ArticleRepositoryIntegrationTest.java | 0 .../test/resources/persistence-h2.properties | 8 +++++ 12 files changed, 97 insertions(+), 5 deletions(-) create mode 100644 persistence-modules/spring-data-jpa-query-3/README.md create mode 100644 persistence-modules/spring-data-jpa-query-3/pom.xml create mode 100644 persistence-modules/spring-data-jpa-query-3/src/main/java/com/baeldung/spring/data/jpa/query/QueryApplication.java rename persistence-modules/{spring-data-jpa-query-2 => spring-data-jpa-query-3}/src/main/java/com/baeldung/spring/data/jpa/query/datetime/Article.java (99%) rename persistence-modules/{spring-data-jpa-query-2 => spring-data-jpa-query-3}/src/main/java/com/baeldung/spring/data/jpa/query/datetime/ArticleRepository.java (100%) create mode 100644 persistence-modules/spring-data-jpa-query-3/src/main/resources/application.properties rename persistence-modules/{spring-data-jpa-query-2 => spring-data-jpa-query-3}/src/main/resources/import_entities.sql (100%) create mode 100644 persistence-modules/spring-data-jpa-query-3/src/main/resources/logback.xml rename persistence-modules/{spring-data-jpa-query-2 => spring-data-jpa-query-3}/src/test/java/com/baeldung/spring/data/jpa/query/datetime/ArticleRepositoryIntegrationTest.java (100%) create mode 100644 persistence-modules/spring-data-jpa-query-3/src/test/resources/persistence-h2.properties diff --git a/persistence-modules/pom.xml b/persistence-modules/pom.xml index 4d42ff54cd..110118f88c 100644 --- a/persistence-modules/pom.xml +++ b/persistence-modules/pom.xml @@ -75,6 +75,7 @@ spring-data-jpa-filtering spring-data-jpa-query spring-data-jpa-query-2 + spring-data-jpa-query-3 spring-data-jpa-repo spring-data-jpa-repo-2 spring-data-jdbc diff --git a/persistence-modules/spring-data-jpa-query-2/README.md b/persistence-modules/spring-data-jpa-query-2/README.md index 36875c899c..8005bc0e19 100644 --- a/persistence-modules/spring-data-jpa-query-2/README.md +++ b/persistence-modules/spring-data-jpa-query-2/README.md @@ -1,18 +1,17 @@ ## Spring Data JPA - Query -This module contains articles about querying data using Spring Data JPA +This module contains articles about querying data using Spring Data JPA . + +### Relevant Articles: -### Relevant Articles: - [Spring Data JPA @Query](https://www.baeldung.com/spring-data-jpa-query) - [Use Criteria Queries in a Spring Data Application](https://www.baeldung.com/spring-data-criteria-queries) -- [Query Entities by Dates and Times with Spring Data JPA](https://www.baeldung.com/spring-data-jpa-query-by-date) - [Hibernate Pagination](https://www.baeldung.com/hibernate-pagination) - [Sorting with Hibernate](https://www.baeldung.com/hibernate-sort) - [Stored Procedures with Hibernate](https://www.baeldung.com/stored-procedures-with-hibernate-tutorial) - [Eager/Lazy Loading In Hibernate](https://www.baeldung.com/hibernate-lazy-eager-loading) - [Auditing with JPA, Hibernate, and Spring Data JPA](https://www.baeldung.com/database-auditing-jpa) - -- More articles: [[<-- prev]](../spring-data-jpa-query) +- More articles: [[<-- prev]](../spring-data-jpa-query)[[more -->]](../spring-data-jpa-query-3) ### Eclipse Config After importing the project into Eclipse, you may see the following error: diff --git a/persistence-modules/spring-data-jpa-query-3/README.md b/persistence-modules/spring-data-jpa-query-3/README.md new file mode 100644 index 0000000000..246b6ebf3d --- /dev/null +++ b/persistence-modules/spring-data-jpa-query-3/README.md @@ -0,0 +1,16 @@ +## Spring Data JPA - Query + +This module contains articles about querying data using Spring Data JPA. + +### Relevant Articles: +- [Query Entities by Dates and Times with Spring Data JPA](https://www.baeldung.com/spring-data-jpa-query-by-date) +- More articles: [[<-- prev]](../spring-data-jpa-query-2) + +### 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-3/pom.xml b/persistence-modules/spring-data-jpa-query-3/pom.xml new file mode 100644 index 0000000000..66a4486bc8 --- /dev/null +++ b/persistence-modules/spring-data-jpa-query-3/pom.xml @@ -0,0 +1,32 @@ + + + 4.0.0 + spring-data-jpa-query-3 + spring-data-jpa-query-3 + + + com.baeldung + parent-boot-2 + 0.0.1-SNAPSHOT + ../../parent-boot-2 + + + + + org.springframework.boot + spring-boot-starter-data-jpa + + + com.h2database + h2 + + + org.springframework.boot + spring-boot-starter-test + test + + + + diff --git a/persistence-modules/spring-data-jpa-query-3/src/main/java/com/baeldung/spring/data/jpa/query/QueryApplication.java b/persistence-modules/spring-data-jpa-query-3/src/main/java/com/baeldung/spring/data/jpa/query/QueryApplication.java new file mode 100644 index 0000000000..48c29eda23 --- /dev/null +++ b/persistence-modules/spring-data-jpa-query-3/src/main/java/com/baeldung/spring/data/jpa/query/QueryApplication.java @@ -0,0 +1,13 @@ +package com.baeldung.spring.data.jpa.query; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class QueryApplication { + + public static void main(String[] args) { + SpringApplication.run(QueryApplication.class, args); + } + +} diff --git a/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/spring/data/jpa/query/datetime/Article.java b/persistence-modules/spring-data-jpa-query-3/src/main/java/com/baeldung/spring/data/jpa/query/datetime/Article.java similarity index 99% rename from persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/spring/data/jpa/query/datetime/Article.java rename to persistence-modules/spring-data-jpa-query-3/src/main/java/com/baeldung/spring/data/jpa/query/datetime/Article.java index bb0e4e88df..1506285f8b 100644 --- a/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/spring/data/jpa/query/datetime/Article.java +++ b/persistence-modules/spring-data-jpa-query-3/src/main/java/com/baeldung/spring/data/jpa/query/datetime/Article.java @@ -9,10 +9,13 @@ public class Article { @Id @GeneratedValue private Integer id; + @Temporal(TemporalType.DATE) private Date publicationDate; + @Temporal(TemporalType.TIME) private Date publicationTime; + @Temporal(TemporalType.TIMESTAMP) private Date creationDateTime; diff --git a/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/spring/data/jpa/query/datetime/ArticleRepository.java b/persistence-modules/spring-data-jpa-query-3/src/main/java/com/baeldung/spring/data/jpa/query/datetime/ArticleRepository.java similarity index 100% rename from persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/spring/data/jpa/query/datetime/ArticleRepository.java rename to persistence-modules/spring-data-jpa-query-3/src/main/java/com/baeldung/spring/data/jpa/query/datetime/ArticleRepository.java diff --git a/persistence-modules/spring-data-jpa-query-3/src/main/resources/application.properties b/persistence-modules/spring-data-jpa-query-3/src/main/resources/application.properties new file mode 100644 index 0000000000..f37cce0b29 --- /dev/null +++ b/persistence-modules/spring-data-jpa-query-3/src/main/resources/application.properties @@ -0,0 +1 @@ +spring.jpa.defer-datasource-initialization=true \ No newline at end of file diff --git a/persistence-modules/spring-data-jpa-query-2/src/main/resources/import_entities.sql b/persistence-modules/spring-data-jpa-query-3/src/main/resources/import_entities.sql similarity index 100% rename from persistence-modules/spring-data-jpa-query-2/src/main/resources/import_entities.sql rename to persistence-modules/spring-data-jpa-query-3/src/main/resources/import_entities.sql diff --git a/persistence-modules/spring-data-jpa-query-3/src/main/resources/logback.xml b/persistence-modules/spring-data-jpa-query-3/src/main/resources/logback.xml new file mode 100644 index 0000000000..56af2d397e --- /dev/null +++ b/persistence-modules/spring-data-jpa-query-3/src/main/resources/logback.xml @@ -0,0 +1,19 @@ + + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + + + + + + + + + + + + \ No newline at end of file diff --git a/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/spring/data/jpa/query/datetime/ArticleRepositoryIntegrationTest.java b/persistence-modules/spring-data-jpa-query-3/src/test/java/com/baeldung/spring/data/jpa/query/datetime/ArticleRepositoryIntegrationTest.java similarity index 100% rename from persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/spring/data/jpa/query/datetime/ArticleRepositoryIntegrationTest.java rename to persistence-modules/spring-data-jpa-query-3/src/test/java/com/baeldung/spring/data/jpa/query/datetime/ArticleRepositoryIntegrationTest.java diff --git a/persistence-modules/spring-data-jpa-query-3/src/test/resources/persistence-h2.properties b/persistence-modules/spring-data-jpa-query-3/src/test/resources/persistence-h2.properties new file mode 100644 index 0000000000..e5853ae523 --- /dev/null +++ b/persistence-modules/spring-data-jpa-query-3/src/test/resources/persistence-h2.properties @@ -0,0 +1,8 @@ +jdbc.driverClassName=org.h2.Driver +jdbc.url=jdbc:h2:mem:test +jdbc.user=sa +jdbc.pass= + +hibernate.dialect=org.hibernate.dialect.H2Dialect +hibernate.show_sql=false +hibernate.hbm2ddl.auto=create-drop