Merge pull request #9896 from kwoyke/JAVA-2305
JAVA-2305: Move Use Criteria Queries in a Spring Data Application to spring-data-jpa-query-2
This commit is contained in:
commit
af4e2397ea
|
@ -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
|
|
@ -0,0 +1,33 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>spring-data-jpa-query</artifactId>
|
||||
<name>spring-data-jpa-query-2</name>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-boot-2</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../../parent-boot-2</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-jpa</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.h2database</groupId>
|
||||
<artifactId>h2</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
|
@ -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<Book> findBooksByAuthorNameAndTitle(String authorName, String title);
|
|
@ -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 {
|
|
@ -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 {
|
||||
|
|
@ -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:
|
||||
|
|
|
@ -7,7 +7,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)
|
||||
- More articles: [[next -->]](/spring-jpa-2)
|
||||
|
||||
### Eclipse Config
|
||||
|
|
Loading…
Reference in New Issue