日期:2014-05-18  浏览次数:20633 次

垃圾的hibernate
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)