1、hibernate常见错误
1.1、INFO: HHH000221: Reading mappings from resource: com/project/pojo/XXX.hbm.xml
观察hibernate.cfg.xml中配置映射文件与实体的XXX.hbm.xml文件名或路径是否匹配
1.2、Caused by: org.hibernate.MappingException: class com.project.pojo.XXX not found while looking for property: address
查看XXXhbm.xml配置文件中配置class时指定XXX 类名是否错误
1.3、WARN: Duplicate entry '1' for key 'UK_g7lva1iq7awttf0yf6iqcte8d'
重复条目(违法唯一键约束)
1.4、IllegalArgumentException occurred while calling setter for property [com.project.pojo.Person.id (expected type = int)]; target = [com.project.pojo.Person@5a9b32ce], property value = [1001]
查看com.project.pojo.Person.id的数据类型与set的值不一致(从表与主表有ID一对一约束,当设置主表id时,从表保存的id也是主表的id,所以主表id类型与从表id类型应相同)