org.hibernate.id.IdentifierGenerationException错误解析


type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.springframework.orm.hibernate3.HibernateSystemException: ids for this class must be manually assigned before calling save(): com.qq.entity.TUser; nested exception is org.hibernate.id.IdentifierGenerationException: ids for this class must be manually assigned before calling save(): com.qq.entity.TUser
	org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:679)
	org.springframework.orm.hibernate3.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:412)
	org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:411)
	org.springframework.orm.hibernate3.HibernateTemplate.executeWithNativeSession(HibernateTemplate.java:374)
	org.springframework.orm.hibernate3.HibernateTemplate.save(HibernateTemplate.java:683)
	com.qq.dao.StudentDAO.saveStudent(StudentDAO.java:46)
	com.qq.service.StudentService.saveStudent(StudentService.java:48)
	com.qq.service.StudentService$$FastClassByCGLIB$$583e69d4.invoke(<generated>)
	net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:191)
	org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:692)
	org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
	org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:108)
	org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
	org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
	org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
	org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:625)
	com.qq.service.StudentService$$EnhancerByCGLIB$$bb3b92d7.saveStudent(<generated>)
	com.qq.action.StudentAction.addStudent(StudentAction.java:157)
	sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)......
 
 
错误位置:映射文件中的ID 是否为native
Hibernate 提供的内置标识符生成器OID
1. increment: 适用于代理主键, 由Hibernate自动以递增的方式生成标识符, 每次递增为1
2. identity:  适用于代理主键, 由底层数据库生成标识符. 前提是底层数据库支持自动增长字段类型
3. sequence:  适用于代理主键, Hibernate根据底层数据库的序列生成标识符. 前提是底层数据库支持序列
4. hilo:      适用于代理主键, Hibernate根据hi/low算法生成标识符. Hibernate把特定的字段作为"high".
5. native:    适用于代理主键, 根据底层数据库对自动生成标识符的支持能力, 来选择identity, sequence, 或hilo
6. uuid.hex:  适用于代理主键, Hibernate采用128位的UUID(Universal Identification)算法生成标识符. 
7. assigned:  适用于自然主键, 由Java应用程序生成标识符.为了能让Java应用程序设置OID,不要把方法声明为private类型.应当尽量避免使用自然主键.

                
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值