第十本书 hibernate5 初学错误记录

阅读更多

W3C课程

 

1, hibernate5 报错org.hibernate.boot.MappingNotFoundException: Mapping (RESOURCE) not found
hibernate.cfg.xml 要跟实体类放一起
hibernate.cfg.xml 中的mapping 要指定文件夹
  com/liu/test/Employee.hbm.xml"/>

2,Failed to create sessionFactory object.org.hibernate.MappingException: entity class not found: Employee 
hibernate.hbm.xml 的class name:
com.liu.test.Employee" table="EMPLOYEE">

3,jdbc4.MySQLSyntaxErrorException: Unknown column 'first_name' in 'field list'

hibernate.hbm.xml 列的是'first_name'
建表时写的是 'fist_name' ; 一字母之差

 

5.使用注解:

org.hibernate.MappingException: Unknown entity: com.liu.orm.Employee

配置文件里要有这句:

 

6.

@GeneratedValue换成@GeneratedValue(strategy = GenerationType.IDENTITY)

 

 https://www.w3cschool.cn/hibernate/npyd1iek.html

 

你可能感兴趣的:(第十本书 hibernate5 初学错误记录)