Hibernate单向一对多应注意的问题2011-09-09这个 问题困扰我10多天,终于干掉了。本人使用myeclipse6.5ga,进行hibernate一对多单向关联实例。一直报如下异常: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) ..................//太长发不了。省略点 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 保存对象student.Student失败! 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) ...........................//太长发不了。省略点 Caused by: java.sql.SQLException: Field "sid" doesn"t have a default value at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1055)测试程序如下: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(); ----------------------------------------------------------------------------------------------------------------------