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类型.应当尽量避免使用自然主键.