SSH框架,mysql数据库,该表主键为string类型,增删查都没有问题,只有修改时出现错误org.springframework.orm.hibernate3.HibernateSystemException:ids for this class must be manually assigned before calling save():njau.edu.model.Dep

来源:学生作业帮助网 编辑:作业帮 时间:2024/07/08 12:27:44
SSH框架,mysql数据库,该表主键为string类型,增删查都没有问题,只有修改时出现错误org.springframework.orm.hibernate3.HibernateSystemException:ids for this class must be manually assigned before calling save():njau.edu.model.Dep
xV_OG*<DPQ5Z8_k͝M6c0`McQlCB}wIw:]TjJngv7,㱉'd7Rdј KS4NJ4nNUm־jӃDhOܕ.{]aUw$;ҫ|Дeo\]ш곲Aft%?Q="ikJ?xN-qj!cq5=V(R +" #1(ZB !bSH ecG%!`BD8,O>gq_ C ^:I8ZAUgT5+MJ;[z{98_X5NꜮU!Koͬ V(l;E7" 8"mx irLt {J'`|3g6Mݕ]P+\:ׯD-V",[OTA7^Lsz:"l_H#E7[4%coަVrv@Yjv*fm <747'NG;h|Y?4X `l`[_ hDOӕ@U-c>wygp *r+ɬv̶[c`&@<+pk#zBs7HJVK1Mz| % ȱ(Z0\a]z8pGIvJs gK3WpAͤv1(t{5}_ՓJ'SfcKS?|.Oѹ{. ߺʋd@vbJ`}5:n@`1 =SXJb&lpg)ϋk X94?,p!V4D3v;+d ~LHP5<:`SuŖGMT

SSH框架,mysql数据库,该表主键为string类型,增删查都没有问题,只有修改时出现错误org.springframework.orm.hibernate3.HibernateSystemException:ids for this class must be manually assigned before calling save():njau.edu.model.Dep
SSH框架,mysql数据库,该表主键为string类型,增删查都没有问题,只有修改时出现错误
org.springframework.orm.hibernate3.HibernateSystemException:ids for this class must be manually assigned before calling save():njau.edu.model.Department; nested exception is org.hibernate.id.IdentifierGenerationException:ids for this class must be manually assigned before calling save():njau.edu.model.Department

SSH框架,mysql数据库,该表主键为string类型,增删查都没有问题,只有修改时出现错误org.springframework.orm.hibernate3.HibernateSystemException:ids for this class must be manually assigned before calling save():njau.edu.model.Dep
引起问题的原因:
由Hibernate根据数据库表自动生成的"类名.hbm.xml"映射文件引起的.
很关键的一点
下面是转来的:
--------------------------------------------------------------------------------
“assigned”
主键由外部程序负责生成,在 save() 之前指定一个.
“hilo”
通过hi/lo 算法实现的主键生成机制,需要额外的数据库表或字段提供高位值来源.
“seqhilo”
与hilo 类似,通过hi/lo 算法实现的主键生成机制,需要数据库中的 Sequence,适用于支持 Sequence 的数据库,如Oracle.
“increment”
主键按数值顺序递增.此方式的实现机制为在当前应用实例中维持一个变量,以保存着当前的最大值,之后每次需要生成主键的时候将此值加1作为主键.这种方式可能产生的问题是:不能在集群下使用.
“identity”
采用数据库提供的主键生成机制.如DB2、SQL Server、MySQL 中的主键生成机制.
“sequence”
采用数据库提供的 sequence 机制生成主键.如 Oralce 中的Sequence.
“native”
由 Hibernate 根据使用的数据库自行判断采用 identity、hilo、sequence 其中一种作为主键生成方式.
“uuid.hex”
由 Hibernate 基于128 位 UUID 算法 生成16 进制数值(编码后以长度32 的字符串表示)作为主键.
“uuid.string”
与uuid.hex 类似,只是生成的主键未进行编码(长度16),不能应用在 PostgreSQL 数据库中.
“foreign”
使用另外一个相关联的对象的标识符作为主键.
--------------------------------------------------------------------------------
看了上面的介绍,再看看代码,应该是属性设置有问题.