質問するログイン新規登録

質問編集履歴

1

ソースコードの追加

2020/02/03 04:31

投稿

isisisimylife
isisisimylife

スコア42

title CHANGED
File without changes
body CHANGED
@@ -16,7 +16,91 @@
16
16
  Pageable pageable = new PageRequest(0, 3, Sort.unsorted());
17
17
  Page<Customer> page = customerRepository.findAllByName(pageable);
18
18
  ```
19
+ ###pom.xml
20
+ ```
21
+ <?xml version="1.0" encoding="UTF-8"?>
22
+ <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
23
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
24
+ <modelVersion>4.0.0</modelVersion>
25
+ <parent>
26
+ <groupId>org.springframework.boot</groupId>
27
+ <artifactId>spring-boot-starter-parent</artifactId>
28
+ <version>2.2.4.RELEASE</version>
29
+ <relativePath/> <!-- lookup parent from repository -->
30
+ </parent>
31
+ <groupId>com.example</groupId>
32
+ <artifactId>hajiboot-jpa</artifactId>
33
+ <version>0.0.1-SNAPSHOT</version>
34
+ <name>hajiboot-jpa</name>
35
+ <description>Demo project for Spring Boot</description>
19
36
 
37
+ <properties>
38
+ <java.version>1.8</java.version>
39
+ </properties>
40
+
41
+ <dependencies>
42
+ <dependency>
43
+ <groupId>org.springframework.boot</groupId>
44
+ <artifactId>spring-boot-starter-data-jpa</artifactId>
45
+ </dependency>
46
+
47
+ <dependency>
48
+ <groupId>com.h2database</groupId>
49
+ <artifactId>h2</artifactId>
50
+ <scope>runtime</scope>
51
+ </dependency>
52
+ <dependency>
53
+ <groupId>org.projectlombok</groupId>
54
+ <artifactId>lombok</artifactId>
55
+ <optional>true</optional>
56
+ </dependency>
57
+ <dependency>
58
+ <groupId>org.springframework.boot</groupId>
59
+ <artifactId>spring-boot-starter-test</artifactId>
60
+ <scope>test</scope>
61
+ <exclusions>
62
+ <exclusion>
63
+ <groupId>org.junit.vintage</groupId>
64
+ <artifactId>junit-vintage-engine</artifactId>
65
+ </exclusion>
66
+ </exclusions>
67
+ </dependency>
68
+ <dependency>
69
+ <groupId>org.lazyluke</groupId>
70
+ <artifactId>log4jdbc-remix</artifactId>
71
+ <version>0.2.7</version>
72
+ </dependency>
73
+ </dependencies>
74
+
75
+ <build>
76
+ <plugins>
77
+ <plugin>
78
+ <groupId>org.springframework.boot</groupId>
79
+ <artifactId>spring-boot-maven-plugin</artifactId>
80
+ </plugin>
81
+ </plugins>
82
+ </build>
83
+
84
+ </project>
85
+ ```
86
+ ###CustomerRepository.java
87
+ ```java
88
+ package com.example.hajibootjpa.repository;
89
+
90
+ import com.example.hajibootjpa.domain.Customer;
91
+ import org.springframework.data.domain.Page;
92
+ import org.springframework.data.domain.Pageable;
93
+ import org.springframework.data.jpa.repository.JpaRepository;
94
+ import org.springframework.data.jpa.repository.Query;
95
+
96
+ import java.util.List;
97
+
98
+ public interface CustomerRepository extends JpaRepository<Customer, Integer> {
99
+ @Query("SELECT x FROM Customer x ORDER BY x.firstName, x.lastName")
100
+ Page<Customer> findAllByName(Pageable pageable);
101
+ }
102
+
103
+ ```
20
104
  ### 試したこと
21
105
  ネットで調べて"PageRequest.of()"を使おうとしたのですが、これまたエラーとなりました。
22
106
  ```