具有Postgresql-primary_id的Spring Session JDBC违反了非空约束

时间:2018-08-23 16:46:45

标签: spring session jdbc

我一直试图将会话数据持久保存到我的postgresql数据库中。我遵循了春季现场的指导原则。一切似乎都运行良好。但是在我的应用程序启动时,出现此错误:

SQL [INSERT INTO SPRING_SESSION(SESSION_ID, 
CREATION_TIME, LAST_ACCESS_TIME, MAX_INACTIVE_INTERVAL, 
PRINCIPAL_NAME) VALUES (?, ?, ?, ?, ?)]; ERROR: null value in column 
"primary_id" violates not-null constraint Detail: Failing row contains 
(null, 835a7b12-d171-4f77-bd22-7da7ed78ca12, 1510171280672, 
1510171280672, 1800, null, null).; nested exception is 
org.postgresql.util.PSQLException: ERROR: null value in column 
"primary_id" violates not-null constraint Detail: Failing row contains 
(null, 835a7b12-d171-4f77-bd22-7da7ed78ca12, 1510171280672, 
1510171280672, 1800, null, null).

下面是从github示例脚本中提取的我的SQL脚本1,请有人帮我弄清楚问题出在哪里吗?

    CREATE TABLE SPRING_SESSION (
  PRIMARY_ID CHAR(36) NOT NULL,
  SESSION_ID CHAR(36) NOT NULL,
  CREATION_TIME BIGINT NOT NULL,
  LAST_ACCESS_TIME BIGINT NOT NULL,
  MAX_INACTIVE_INTERVAL INT NOT NULL,
  EXPIRY_TIME BIGINT NOT NULL,
  PRINCIPAL_NAME VARCHAR(100),
  CONSTRAINT SPRING_SESSION_PK PRIMARY KEY (PRIMARY_ID)
);

CREATE UNIQUE INDEX SPRING_SESSION_IX1 ON SPRING_SESSION (SESSION_ID);
CREATE INDEX SPRING_SESSION_IX2 ON SPRING_SESSION (EXPIRY_TIME);
CREATE INDEX SPRING_SESSION_IX3 ON SPRING_SESSION (PRINCIPAL_NAME);

CREATE TABLE SPRING_SESSION_ATTRIBUTES (
  SESSION_PRIMARY_ID CHAR(36) NOT NULL,
  ATTRIBUTE_NAME VARCHAR(200) NOT NULL,
  ATTRIBUTE_BYTES LONGVARBINARY NOT NULL,
  CONSTRAINT SPRING_SESSION_ATTRIBUTES_PK PRIMARY KEY (SESSION_PRIMARY_ID, ATTRIBUTE_NAME),
  CONSTRAINT SPRING_SESSION_ATTRIBUTES_FK FOREIGN KEY (SESSION_PRIMARY_ID) REFERENCES SPRING_SESSION(PRIMARY_ID) ON DELETE CASCADE
);

CREATE INDEX SPRING_SESSION_ATTRIBUTES_IX1 ON SPRING_SESSION_ATTRIBUTES (SESSION_PRIMARY_ID);

0 个答案:

没有答案