質問編集履歴
1
エラーメッセージ・dbなど追記しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
|
7
7
|
1つのフォームで、2つのテーブルの内容を登録したくて、OneToOne結合しています。
|
8
8
|
|
9
|
-
主のテーブルの自動採番は
|
9
|
+
主のテーブルの自動採番(mst_sensorのsensor_id、mst_mailのmail_id)はinsert文に表示されていますが、その採番されたID(sensor_id)を結合先のテーブル(mst_mail)に登録したいのですが、nullとなり登録できずに困っています。
|
10
10
|
|
11
11
|
よろしくお願いします。
|
12
12
|
|
@@ -14,13 +14,19 @@
|
|
14
14
|
|
15
15
|
### 発生している問題・エラーメッセージ
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
```
|
17
|
+
```
|
18
|
+
|
19
|
+
10. insert into mst_sensor (sensor_name, updatedata, sensor_id) values ('AA11', '05/25/2018 09:54:22.253', 36) {executed in 66 msec}
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
10. insert into mst_mail (sensor_id, sendmail_address, sendmail_threshold, updatedata, mail_id) values (NULL, NULL, 1, '05/25/2018 09:54:22.047', 11) {FAILED after 47 msec}
|
24
|
+
|
25
|
+
|
20
26
|
|
21
27
|
org.postgresql.util.PSQLException: ERROR: null value in column "sensor_id" violates not-null constraint
|
22
28
|
|
23
|
-
詳細: Failing row contains (null, 0, 1, null, 2018-05-2
|
29
|
+
詳細: Failing row contains (null, 0, 1, null, 2018-05-25 09:54:22.047, 11).
|
24
30
|
|
25
31
|
```
|
26
32
|
|
@@ -28,9 +34,91 @@
|
|
28
34
|
|
29
35
|
### 該当のソースコード
|
30
36
|
|
31
|
-
|
37
|
+
postgresql
|
38
|
+
|
32
|
-
|
39
|
+
```
|
40
|
+
|
41
|
+
\d mst_sensor
|
42
|
+
|
43
|
+
Table "public.mst_sensor"
|
44
|
+
|
45
|
+
Column | Type | Collation | Nullable | Default
|
46
|
+
|
47
|
+
-------+------+-----------+----------+--------------------
|
48
|
+
|
49
|
+
sensor_id | integer | | not null | nextval('mst_sensor_sensor_id_seq'::regclass)
|
50
|
+
|
51
|
+
sensor_name | character varying(30) | | not null |
|
52
|
+
|
53
|
+
updatedata | timestamp without time zone | | not null |
|
54
|
+
|
55
|
+
Indexes:
|
56
|
+
|
57
|
+
"mst_sensor_pkey" PRIMARY KEY, btree (sensor_id)
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
\d mst_sensor_sensor_id_seq
|
64
|
+
|
65
|
+
Sequence "public.mst_sensor_sensor_id_seq"
|
66
|
+
|
67
|
+
Type | Start | Minimum | Maximum | Increment | Cycles? | Cache
|
68
|
+
|
69
|
+
-----+-------+---------+---------+-----------+---------+-------
|
70
|
+
|
71
|
+
integer | 1 | 1 | 2147483647 | 1 | no | 1
|
72
|
+
|
73
|
+
Owned by: public.mst_sensor.sensor_id
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
\d mst_mail
|
80
|
+
|
81
|
+
Table "public.mst_mail"
|
82
|
+
|
83
|
+
Column | Type | Collation | Nullable | Default
|
84
|
+
|
85
|
+
-------+------+-----------+----------+-----------------------
|
86
|
+
|
87
|
+
sensor_id | integer | | not null |
|
88
|
+
|
89
|
+
sendmail_threshold | integer | | |
|
90
|
+
|
91
|
+
sendmail_address | character varying(128) | | |
|
92
|
+
|
93
|
+
updatedata | timestamp without time zone | | not null |
|
94
|
+
|
95
|
+
mail_id | integer | | not null | nextval('mst_mail_mail_id_seq'::regclass)
|
96
|
+
|
97
|
+
Indexes:
|
98
|
+
|
99
|
+
"mst_mail_pkey" PRIMARY KEY, btree (mail_id)
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
\d mst_mail_mail_id_seq
|
106
|
+
|
107
|
+
Sequence "public.mst_mail_mail_id_seq"
|
108
|
+
|
109
|
+
Type | Start | Minimum | Maximum | Increment | Cycles? | Cache
|
110
|
+
|
111
|
+
-----+-------+---------+---------+-----------+---------+-------
|
112
|
+
|
113
|
+
bigint | 1 | 1 | 9223372036854775807 | 1 | no | 1
|
114
|
+
|
115
|
+
```
|
116
|
+
|
117
|
+
|
118
|
+
|
33
|
-
|
119
|
+
Machine.java
|
120
|
+
|
121
|
+
```java
|
34
122
|
|
35
123
|
@Data
|
36
124
|
|
@@ -144,7 +232,9 @@
|
|
144
232
|
|
145
233
|
|
146
234
|
|
147
|
-
|
235
|
+
MachineMailAdd.java
|
236
|
+
|
237
|
+
```java
|
148
238
|
|
149
239
|
@Data
|
150
240
|
|
@@ -262,7 +352,9 @@
|
|
262
352
|
|
263
353
|
|
264
354
|
|
265
|
-
|
355
|
+
MachineController.java
|
356
|
+
|
357
|
+
```java
|
266
358
|
|
267
359
|
@RequestMapping("add")
|
268
360
|
|