简体   繁体   中英

org.hibernate.exception.GenericJDBCException

@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

I am getting the following exception. i am reading the content from the file and saving in the data base. ICCID value will be given from file. Actually I am setting the file content value to ICCID,can u help me out with where i am going wrong.

You must configure the hbm2ddl.auto in the hibernate configuration file :

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

after run 1 time the app .

and change it to update , like this :

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

The problem is you have some old values inserted in the table and when you want to change the schema , there is no default value for those old values .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM