学习hibernate遇到的问题1

来源:互联网 发布:知无涯者书 编辑:程序博客网 时间:2024/05/29 11:55

今天初学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是自增的,然而在数据库中我没有定义成自增的,所以出错。

0 0
原创粉丝点击