hibernate常见错误及解决方法总结
来源:互联网 发布:淘宝买的ipad靠谱吗 编辑:程序博客网 时间:2024/06/06 02:55
1、org.hibernate.PropertyNotFoundException: field [cid] not found on org.sihai.shop.categorySecond.CategorySecond
解决:一般是在hbm.xml文件中的属性和实体中的属性不对应。
2、org.hibernate.MappingException: An association from the table product refers to an unmapped class: CategorySecond
解决: class需要写全路径
3、mysql删除有外链索引数据Cannot delete or update a parent row: a foreign key constraint fails erty references a null or transient value: org.sihai.shop.product.Product.categorySecond; nested exception is org.hibernate.PropertyValueException: not-null property references a null or transient value: org.sihai.shop.product.Product.categorySecond
解决:在做删除的时候,因为直接获取到的对象是瞬时态的对象,不是持久态,不能删除,所以需要在删除的时候,先根据id查询到这个持久态的对象,然后再删除。
// 后台:删除商品
public String delete() {
product = productService.findByPid(pid);
productService.delete(product);
return “deleteSuccess”;
}
6、object references an unsaved transient instance - save the transient instanc
解决:需要设置级联的对象cascade = “sava-update”,这样才会保存级联的对象。主要的问题在于没有给其对象设置id值,这样的话保存的时候不是一个持久化的对象。
7.Field 'uuid' doesn't have a default value
解决:这是由于在设计表的时候忘记给其主键设置自增了。
8. org.springframework.orm.hibernate3.HibernateSystemException: Unknown entity:
解决:这是因为没有配置实体类的映射文件造成的。
0 0
- hibernate常见错误及解决方法总结
- 常见错误及解决方法
- 常见错误及解决方法
- hibernate中常见的Exception错误及解决方法
- hibernate常见错误总结
- hibernate的常见错误解决方法
- xcode升级后的常见错误及解决方法总结
- 常见错误分析及解决方法
- MOSS2007常见错误及解决方法
- IIS7常见错误及解决方法
- Lpc1768 常见错误及解决方法
- webservice 常见错误及解决方法
- java常见错误及解决方法
- Android常见错误及解决方法
- Oracle 常见错误及解决方法
- VS2012常见错误及解决方法
- C++常见错误及解决方法
- java常见错误及解决方法
- Apple首篇AI文章,SimGAN
- unity3D
- 数据库
- <c:if test=""> 如何做判断?
- codeforces 754D Fedor and coupons (优先队列)
- hibernate常见错误及解决方法总结
- 编辑距离
- HttpClient
- 泛型仿函数一
- 《MySql》--覆盖索引
- Nginx 启动、停止、平滑重启和平滑升级
- 文章标题
- PHP-环境-Lamp环境搭建-生产环境
- ViewPager 详解(二)—详解四大函数