hibernate一直以来都以其自动化而闻名于世,我也看过hibernate in action,确实写的不错。然而今天我不得不说他很垃圾,我写了个程序,一直都报错,从晚上8点到现在,我都不知道具体错在哪儿,如果是好的框架,总该告我哪儿有问题,哪儿可以解决,但是我却丝毫没有看出来。贴上代码,大家帮我看看。
Users.hbm.xml
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="org.okercn.beans.Users" table="users">
<id name="id" column="id" type="java.lang.Integer">
<generator class="identity" />
</id>
<property name="username" column="username"/>
<property name="passwd" column="passwd" />
<property name="usertype" column="usertype" />
<property name="email" column="email" />
<property name="sex" column="sex" />
<property name="realname" column="realname" />
<property name="birthday" column="birthday" />
<property name="question" column="question" />
<property name="answer" column="answer" />
</class>
</hibernate-mapping>
public class BaseDao extends HibernateDaoSupport {
public void save(Object obj) throws Exception {
getSession().save(obj);
}
}
错误如下:
nate: insert into users (username, passwd, usertype, email, sex, realname, birthday, question, answer, id) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
2012-3-29 0:39:57 org.hibernate.util.JDBCExceptionReporter logExceptions
警告: SQL Error: 0, SQLState: 07001
2012-3-29 0:39:57 org.hibernate.util.JDBCExceptionReporter logExceptions
严重: No value specified for parameter 10
org.hibernate.exception.SQLGrammarException: could not insert: [org.okercn.beans.Users]
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.id.insert.AbstractReturningDelegate.performInsert(AbstractReturningDelegate.java:40)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2158)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2638)
at org.hibernate.action.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:48)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:250)
at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:298)
at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:181)
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:107)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:187)
at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:33)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:172)
at org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:27)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
at org.hibernate.impl.SessionImpl.fireSave(SessionImpl.java:535)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:523)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:519)
at org.okercn.dao.BaseDao.save(BaseDao.java:10)
at org.okercn.service.BaseService.save(BaseService.java:12)
at org.okercn.service.BaseService$$FastClassByCGLIB$$5bf622db.invoke(<generated>)
at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)
at org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:700)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:635)
at org.okercn.service.UserService$$EnhancerByCGLIB$$bbe8521f.save(<generated>)
at org.okercn.action.UserAction.regUser(UserAction.java:50)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:441)
at com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:280)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:243)
at com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:165)