ids for this class must be manually assigned before calling save():***错误说明
来源:互联网 发布:easymule 软件 编辑:程序博客网 时间:2024/05/01 08:24
近日研究JSP中使用Hibernate出现了 ids for this class must be manually assigned before calling save():***错误,分析及解决如下:
你要操作的数据表中的id(即主键)的类型设置成了“自动增长类型”,而在hibernate.cfg.xml中,id的生成方式是assigned,即
<id name="id" type="integer">
<column name="id" />
<generator class="assigned" />
</id>
这种搭配是矛盾的!
<id name="id" type="integer">
<column name="id" />
<generator class="assigned" />
</id>
这种搭配是矛盾的!
主键的assigned生成方式由程序自动生成表的主键,即在你的测试程序中要调用setId()方法,且必
须在调用save()前调用(或者说在调用save()前必须指定id,其实就是说,主键值不能为空!)。
把主键的生成方式改为increment,它的特征是能够根据底层数据库自动选择主键生成方式。
把主键的生成方式改为increment,它的特征是能够根据底层数据库自动选择主键生成方式。
至此问题完全解决了。
- ids for this class must be manually assigned before calling save():***错误说明
- ids for this class must be manually assigned before calling save():***错误说明
- error:ids for this class must be manually assigned before calling save():
- error:ids for this class must be manually assigned before calling save()
- ids for this class must be manually assigned before calling save()
- error:ids for this class must be manually assigned before calling save():
- ids for this class must be manually assigned before calling save() hibernate
- org.hibernate.id.IdentifierGenerationException: ids for this class must be manually assigned before calling save():
- IdentifierGenerationException: ids for this class must be manually assigned before calling save()
- ids for this class must be manually assigned before calling save()..
- HibernateSystemException--ids for this class must be manually assigned before calling save()
- error:ids for this class must be manually assigned before calling save():
- 关于 error:ids for this class must be manually assigned before calling save(): 的解决方案
- ids for this class must be manually assigned before calling save():
- 工作札记--“ids for this class must be manually assigned before calling save”解决办法
- ids for this class must be manually assigned before calling save()..
- ids for this class must be manually assigned before calling save()
- message ids for this class must be manually assigned before calling save(): ID 的问题
- event.x,event.clientX,event.offsetX区别
- 智能温度表(下位机)简介
- load balanced cluster
- 入门着怎样建一个普通的触发器
- 温(湿)度测量系统主机简介
- ids for this class must be manually assigned before calling save():***错误说明
- 闲谈 选择自 fengzi_zhu 的 Blog
- XML知识1--xml格式熟悉
- 段错误bug的调试
- java中的类和方法的修饰符(转)
- 自定义TabControl全部代码
- 谈PHP生成静态页面
- T_Monitor温湿度监控软件简介
- windows安装基于Apache的SVN服务器(包括SSL配置)