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

質問編集履歴

2

バージョンの追記

2021/02/09 10:39

投稿

tsizuku
tsizuku

スコア7

title CHANGED
File without changes
body CHANGED
@@ -4,6 +4,11 @@
4
4
  含んでいると起動時に異常終了してしまいます。
5
5
  解決策はありますでしょうか?
6
6
 
7
+ ◆環境
8
+ Spring Tool Suite 4 Version: 4.8.1
9
+ SpringBoot2
10
+ Java8
11
+
7
12
  ◆リボジトリ
8
13
  ```ここに言語を入力
9
14
  @Repository

1

コードの追記

2021/02/09 10:39

投稿

tsizuku
tsizuku

スコア7

title CHANGED
File without changes
body CHANGED
@@ -3,6 +3,64 @@
3
3
  テーブルのカラム名が”EMPL_ID”のような”ID”のキーワードを
4
4
  含んでいると起動時に異常終了してしまいます。
5
5
  解決策はありますでしょうか?
6
- 例えば
7
- fingByEMPL_ID(String emplid)
8
- のような感じです。
6
+
7
+ ◆リボジトリ
8
+ ```ここに言語を入力
9
+ @Repository
10
+ public interface BsLoginUserRPS extends JpaRepository<BsLoginUser,String>{
11
+
12
+ // JPAメソッドによるQuary自動生成(カラム名に連動)
13
+ public Optional<BsLoginUser> findByLOGIN_IDAndCOMPANY_ID(String lid,String cid);
14
+ }
15
+ ```
16
+
17
+ ◆テーブル
18
+ ```ここに言語を入力
19
+ CREATE TABLE BS_LOGIN_USER
20
+ (
21
+ LOGIN_ID VARCHAR2(8) NOT NULL ENABLE,
22
+ COMPANY_ID VARCHAR2(20),
23
+ PASSWORD VARCHAR2(50),
24
+ NAME NVARCHAR2(20)
25
+ )
26
+ ```
27
+
28
+ ◆エンティティ
29
+ ```ここに言語を入力
30
+ @Entity
31
+ @Table(name = "BS_LOGIN_USER")
32
+ public class BsLoginUser {
33
+
34
+ /**
35
+ * loginIdプロパティ
36
+ */
37
+ @Id
38
+ @Column(name = "LOGIN_ID")
39
+ public String loginId;
40
+
41
+ /**
42
+ * companyIdプロパティ
43
+ */
44
+ @Column(name = "COMPANY_ID")
45
+ public String companyId;
46
+
47
+ /**
48
+ * passwordプロパティ
49
+ */
50
+ @Column(name = "PASSWORD")
51
+ public String password;
52
+
53
+ /**
54
+ * nameプロパティ
55
+ */
56
+ @Column(name = "NAME")
57
+ public String name;
58
+ }
59
+ ```
60
+ ◆エラー
61
+ ```ここに言語を入力
62
+ Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
63
+ 2021-02-09 11:38:36.795, [ ERROR ], org.springframework.boot.SpringApplication, Application run failed
64
+ org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'loginSevice': Unsatisfied dependency expressed through field 'repository'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'bsLoginUserRPS' defined in jp.psf.shoryu.Repository.BsLoginUserRPS defined in @EnableJpaRepositories declared on JpaRepositoriesRegistrar.EnableJpaRepositoriesConfiguration: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Failed to create query for method public abstract java.util.Optional jp.psf.shoryu.Repository.BsLoginUserRPS.findByLOGIN_IDAndCOMPANY_ID(java.lang.String,java.lang.String)! No property LOGIN found for type BsLoginUser!
65
+
66
+ ```