postgres的自增类型字段的插入异常

xuejunjun 2007-12-22 06:25:35
Test.hbm.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 2.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<class name="tm.bo.hbbean.Test" table="test">
<id name="id" column="id" type="int">
<generator class="increment"/>
</id>
<property name="username" column="username" type="string" length="50"/>
</class>
</hibernate-mapping>

xml里的配置文件是这样的,
postgrest里该id字段的类型是:DATATYPE->bigint Default value -> nextval('test_id_seq'::regclass) and not null;

在action做插入的时候我没有插id字段的值,
结果报异常:
javax.servlet.ServletException: IllegalArgumentException occurred while calling setter of tm.bo.hbbean.Test.id; nested exception is net.sf.hibernate.PropertyAccessException: IllegalArgumentException occurred while calling setter of tm.bo.hbbean.Test.id
org.apache.struts.action.RequestProcessor.processException(RequestProcessor.java:545)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:486)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
...全文
321 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
xuejunjun 2007-12-22
  • 打赏
  • 举报
回复
呵呵已经处理了 是类型不匹配
xuejunjun 2007-12-22
  • 打赏
  • 举报
回复
各位大虾帮忙指点下,小弟刚开始学这个。谢谢啊!

56,675

社区成员

发帖
与我相关
我的任务
社区描述
MySQL相关内容讨论专区
社区管理员
  • MySQL
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧