刚开始学Hibernate`
在做一个表的插入时``出现了个异常`
org.hibernate.exception.GenericJDBCException: Could not execute JDBC batch update
org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:103)
org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:91)
org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:202)
org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:235)
org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:139)
org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:297)
org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
org.hibernate.impl.SessionImpl.flush(SessionImpl.java:985)
org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:333)
org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
cn.pior.struts.action.AddEnforceLawerInfoAction.execute(AddEnforceLawerInfoAction.java:92)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
我到网上查了查``说是有可能是因为SQL中使用了默认关键字的问题``
这是H的输出`
Hibernate: insert into zfryinfo (dwId, bh, zfzh, name, IDCard, sex, brithday, education, bz, station, duty, nation, zzmm, remark, del, ID) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
这里面有默认关键字吗?
这默认关键字都有什么?
以后在设计表时就应该回避这些默认关键字吗??
------解决方法--------------------------------------------------------
配置文件里这么写
<id name= "id " type= "java.lang.Long ">
<column name= "ID " precision= "10 " scale= "0 " />
<generator class= "increment " />
</id>
------解决方法--------------------------------------------------------
org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:91)
转换错误哈.
这个就有很多可能了:比如你传入的字符串长度过长,你java类里面属性的类型和.hbm.xml里面声明不一致都可以造成以上错误。