The question bothered me for more than 10 days and finally got rid of it.
I use Myeclipse6.5ga to hibernate a one-to-many one-way correlation instance.
Always reported the following exception:
Hibernate:
Insert
Into
Hbql.score
(Score, type)
Values
。。。。。。。。。。。。。。。。。。。
17:03:32,484 DEBUG jdbcexceptionreporter:69-could not insert: [Score. Score] [insert INTO Hbql.score (Score, type) VALUES (?,?)]
Java.sql.SQLException:Field ' sid ' doesn ' t have a default value
At Com.mysql.jdbc.SQLError.createSQLException (sqlerror.java:1055)
..../long hair is not good.//* * * Omit point
17:03:32,484 WARN jdbcexceptionreporter:77-sql error:1364, sqlstate:hy000
17:03:32,484 ERROR jdbcexceptionreporter:78-field ' sid ' doesn ' t have a default value
Save object Student. Student failed!
17:03:32,484 DEBUG Jdbctransaction:152-rollback
Org.hibernate.exception.GenericJDBCException:could not insert: [Score. Score]
At Org.hibernate.exception.SQLStateConverter.handledNonSpecificException (sqlstateconverter.java:103)
At Org.hibernate.exception.SQLStateConverter.convert (sqlstateconverter.java:91)
.....//too long hair is not good.///Too much of a lot. Omit point
caused By:java.sql.SQLException:Field ' sid ' doesn ' t have a default value
At Com.mysql.jdbc.SQLError.createSQLException (sqlerror.java:1055)
The test procedure is as follows:
Student student=new Student("huizhi","2708",200);
Score score1=new Score(98,"1");
Score score2=new Score(90,"2");
Set set=new HashSet();
set.add(score1);
set.add(score2);
student.setScores(set);
saveObject(student);
printStudents();
----------------------------------------------------------------------------------------------------------------------