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)