gpt4 book ai didi

java - org.hibernate.exception.GenericJDBCException

转载 作者:行者123 更新时间:2023-11-30 07:50:08 25 4
gpt4 key购买 nike

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name="ICCID", length=100,unique=true, nullable=false)
private String ICCID;
.....

create table DUMMY_DATA(
ICCID VARCHAR(255) NOT NULL ,
IMSI VARCHAR(255) NOT NULL,
PRIMARY KEY (ICCID)
);

2015-10-29 13:13:09,883 WARN [SqlExceptionHelper] (SqlExceptionHelper.java:145) - SQL Error: 1364, SQLState: HY000
2015-10-29 13:13:09,883 ERROR [SqlExceptionHelper] (SqlExceptionHelper.java:147) - Field 'ICCID' doesn't have a default value
Oct 29, 2015 1:13:09 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [dispatcher] in context with path [/globeconnect] threw exception [Request processing failed; nested exception is org.hibernate.exception.GenericJDBCException: could not execute statement] with root cause
java.sql.SQLException: Field 'ICCID' doesn't have a default value

我收到以下异常。我正在从文件中读取内容并将其保存在数据库中。ICCID 值将从文件中给出。实际上我正在将文件内容值设置为 ICCID,你能帮我解决哪里出错了吗?

最佳答案

您必须在 hibernate 配置文件中配置hbm2ddl.auto:

<property name="hbm2ddl.auto">create</property>

运行应用 1 次后。

并将其更改为更新,如下所示:

<property name="hbm2ddl.auto">update</property>

问题是您在表中插入了一些旧值,当您想要更改架构时,这些旧值没有默认值。

关于java - org.hibernate.exception.GenericJDBCException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33408618/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com