質問編集履歴

2

説明分の編集

2019/11/06 15:53

投稿

icezoom
icezoom

スコア36

test CHANGED
File without changes
test CHANGED
@@ -18,11 +18,11 @@
18
18
 
19
19
  @GeneratedValue(strategy = GenerationType.IDENTITY)
20
20
 
21
- private Long bId;
21
+ private Long Id;
22
22
 
23
23
 
24
24
 
25
- private String bNm;
25
+ private String Nm;
26
26
 
27
27
 
28
28
 
@@ -30,11 +30,11 @@
30
30
 
31
31
  @Entity
32
32
 
33
- @Table(name="m_unit")
33
+ @Table
34
34
 
35
35
  @Data
36
36
 
37
- public class MUnit {
37
+ public class User {
38
38
 
39
39
 
40
40
 
@@ -42,8 +42,8 @@
42
42
 
43
43
  @GeneratedValue(strategy = GenerationType.IDENTITY)
44
44
 
45
- private Long uId;
45
+ private Long Id;
46
46
 
47
47
 
48
48
 
49
- private Long bId;
49
+ private Long name;

1

誤字

2019/11/06 15:53

投稿

icezoom
icezoom

スコア36

test CHANGED
File without changes
test CHANGED
@@ -8,65 +8,23 @@
8
8
 
9
9
 
10
10
 
11
- その際のcontroller、serviceでのfindByメソッドの実装方法がわからず、苦戦しています。
12
-
13
- 特に引数の扱いに困っています。
14
-
15
11
 
16
12
 
17
13
 
18
14
 
19
15
  ```Java
20
16
 
21
- @Entity
22
17
 
23
- @Table(name = "m_bldg")
24
-
25
- @Data
26
-
27
- public class MBldg {
28
-
29
- @Id
30
18
 
31
19
  @GeneratedValue(strategy = GenerationType.IDENTITY)
32
20
 
33
- private Long bldgId;
21
+ private Long bId;
34
22
 
35
23
 
36
24
 
37
- private String bldgNm;
25
+ private String bNm;
38
26
 
39
-
40
-
41
- private Long prefId;
27
+
42
-
43
-   
44
-
45
-   private String prefNm;
46
-
47
-
48
-
49
- private Long cityId;
50
-
51
-
52
-
53
-   private string cityNm;
54
-
55
-
56
-
57
- private String town;
58
-
59
-
60
-
61
- private String cho
62
-
63
-
64
-
65
- @OneToMany(mappedBy="mBldg")
66
-
67
- private List<MUnit> mUnitList;
68
-
69
- ```
70
28
 
71
29
  ```Java
72
30
 
@@ -84,120 +42,8 @@
84
42
 
85
43
  @GeneratedValue(strategy = GenerationType.IDENTITY)
86
44
 
87
- private Long unitId;
45
+ private Long uId;
88
46
 
89
47
 
90
48
 
91
- private Long bldgId;
49
+ private Long bId;
92
-
93
-
94
-
95
- private String roomNo;
96
-
97
-
98
-
99
- private Integer layoutNum;
100
-
101
-
102
-
103
- private String layoutKbn;
104
-
105
-   
106
-
107
-   @ManyToOne
108
-
109
- @JoinColumn(name = "bldgId", insertable = false, updatable = false)
110
-
111
- private MBldg mBldg;
112
-
113
- ```
114
-
115
-
116
-
117
- ```Java(repository)
118
-
119
- @Repository
120
-
121
- public interface MUnitRepository extends JpaRepository<MUnit, Long>, JpaSpecificationExecutor<MUnit> {
122
-
123
-
124
-
125
- public List<MUnit> findByBldgNmAndRoomNoAndPrefNmAndCityNmAndTownAndCho
126
-
127
- (String bldgNm,String roomNo,String prefNm, String cityNm, String town,String cho);
128
-
129
-
130
-
131
- }
132
-
133
-
134
-
135
- ```
136
-
137
-
138
-
139
- 下記serviceでの「findByBldgNmAndRoomNoAndPrefNmAndCityNmAndTownAndCho()」
140
-
141
- の引数に何を指定すればよいのかわかりません。
142
-
143
- 単純にrepositoryで指定してある値を入れたらいいのか…
144
-
145
- 理解が足りていないのは、確かだとおもうのですが、どなたか助言等頂けると助かります。
146
-
147
-
148
-
149
- ```Java(service)
150
-
151
- @Service
152
-
153
- public class UnitService {
154
-
155
-
156
-
157
- @Autowired
158
-
159
- MUnitRepository mUnitRepository;
160
-
161
-
162
-
163
- public List<MUnit> search(UnitForm form) throws Exception {
164
-
165
- List <MUnit> result = mUnitRepository.findByBldgNmAndRoomNoAndPrefNmAndCityNmAndTownAndCho();
166
-
167
- return result;
168
-
169
- }
170
-
171
- }
172
-
173
- ```
174
-
175
-
176
-
177
- ```java
178
-
179
- @RestController
180
-
181
- @RequestMapping("/unit")
182
-
183
- public class UnitRestController {
184
-
185
-
186
-
187
- // 戸サービスクラス
188
-
189
- @Autowired
190
-
191
- UnitService unitService;
192
-
193
-
194
-
195
- @RequestMapping(path = "search", method = RequestMethod.GET)
196
-
197
- public String search(UnitForm form, Model model) throws Exception {
198
-
199
- return JsonUtil.convSearchData(unitService.search(form));
200
-
201
- }
202
-
203
- ```