SQL Error: 1364, SQLState: HY000 -(71)
SQL Error: 1364, SQLState: HY000 -(71)
System.out.println(functionTable.getFt_describe() + " " + functionTable.getFt_id() + " " + functionTable.getFt_name() + " " + functionTable.getFt_page()); session.save(functionTable);
functionTable是一个类的对象有四个属性,对应数据库中的四个字段。通过输出在保存之前输出打印四个属性值,都有值。
但执行到save方法时就出错了
异常:
0 F0111 sfefse fsfef
Hibernate: insert into functiontable (ft_name, ft_describe, ft_page) values (?, ?, ?)
2011-08-11 08:48:44 [org.hibernate.util.JDBCExceptionReporter]-[WARN] SQL Error: 1364, SQLState: HY000 -(71)
2011-08-11 08:48:44 [org.hibernate.util.JDBCExceptionReporter]-[ERROR] Field 'ft_id' doesn't have a default value -(72)
org.hibernate.exception.GenericJDBCException: could not insert: [edu.usc.vo.Functiontable]
at org.hibernate.exception.ErrorCodeConverter.handledNonSpecificException(ErrorCodeConverter.java:92)
at org.hibernate.exception.ErrorCodeConverter.convert(ErrorCodeConverter.java:80)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.persister.entity.BasicEntityPersister.insert(BasicEntityPersister.java:1777)
at org.hibernate.persister.entity.BasicEntityPersister.insert(BasicEntityPersister.java:2178)
把hql语句打印出来 insert into functiontable (ft_name, ft_describe, ft_page) values (?, ?, ?)不是Hibernate: insert into functiontable (ft_name, ft_describe, ft_page, ft_id) values (?, ?, ?, ?)。