今天初学hibernate,运行junit test 遇到了三个错误,再次记录一下。
错误1:org.hibernate.HibernateException: Dialect class not found:
原因:在hibernate.cfg.xml中<property
name="dialect">org.hibernate.dialect.MySQLInnoDBDialect</property>大小写写错了注意,MySQLInnoDBDialect别再写错了。
错误2.Hibernate: org.hibernate.exception.SQLGrammarException: could not insert: 错误
原因:数据库方言是MySQLInnoDBDialect,这时需要数据库中的表必须存在,所以需要先建一个表。
错误3.org.hibernate.HibernateException: The database returned no natively generated identity value
原因:在程序中我定义的id是自增的,然而在数据库中我没有定义成自增的,所以出错。