目前的结构采用的是Struts+spring+hibernate,目前遇到一个问题,Riskdutyfactor表与riskDuty是多对多的关系,中间表为factorRiskDuty
配置文件如下:
RISKDUTY表:
xml 代码
- <hibernate-mapping>
- <class name="com.sleb.po.Riskduty" table="RISKDUTY" schema="XFLIU">
- <id name="riskdutyid" type="integer">
- <column name="RISKDUTYID" />
- <generator class="sequence" >
- <param name="sequence">S_RISKDUTY</param>
- </generator>
- </id>
- .....
- <set name="riskdutyrisks" inverse="true">
- <key>
- <column name="RISKDUTYID" />
- </key>
- <one-to-many class="com.sleb.po.Riskdutyrisk" />
- </set>
-
- <set name="riskdutyfactors" table="FACTORRISKDUTY" cascade="save-update">
- <key>
- <column name="RISKDUTYID" />
- </key>
- <many-to-many class="com.sleb.po.Riskdutyfactor" column="RISKDUTYFACTORID" />
- </set>
- </class>
- </hibernate-mapping>
------------------------
riskdutyfactor表映射文件: ----------先对以上进行解释,有一个界面是用来增加RISKDUTYFACTOR表中的数据的,另一个界面用来增加RISKDUTY数据的,在增加RISKDUTY的时候,需要使用RISKDUTYFACTOR表中的数据,由于是多对多的关系,因此增加FACTORRISKDUTY中间表.由以上可以知道riskduty增加的时候,再对中间表进行更新,因此设置RISKDUTY配置文件中的cascade="save-update"> 来维护关系,我想这个是正确的,因为我能正确的增加数据.RiskDutyService程序如下:
-
- public boolean saveRiskduty(String dutyName, String dutyType,
- String[] baseChecked, String[] complexChecked) {
- riskDuty.setDutyname(dutyName);
- riskDuty.setDutytype(dutyType);
- if (baseChecked != null) {
- for (int i = 0; i < baseChecked.length; i++) {
- log.info(this.getRiskDutyFactorByPk(new Integer(baseChecked[i])).getFactorname());
-
- riskDuty.getRiskdutyfactors().add(this.getRiskDutyFactorByPk(new Integer(baseChecked[i])));
- }
- }
- if (complexChecked != null) {
- for (int i = 0; i < complexChecked.length; i++) {
- log.info(this.getRiskDutyFactorByPk(new Integer(complexChecked[i])).getFactorname());
- / 首先根据页面上请求的ID,取得RiskDutyFactor对象,后与RiskDuty关联
- riskDuty.getRiskdutyfactors().add(this.getRiskDutyFactorByPk(new Integer(complexChecked[i])));
- }
- }
- log.info("begin save complexCheck riskDuty");
- this.getRiskDutyDAO().save(riskDuty);
-
- bl=true;
-
-
- return bl;
- }
第一次增加riskduty是没有任何问题的,但是第2次的时候,报如下错误:org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session: [com.sleb.po.Riskdutyfactor#1]
----------我知道出现的问题是在this.getRiskDutyFactorByPk(new Integer(baseChecked[i]))); 但是在网上找了很对解决办法,都没有实现,比较纳闷,所以写在自己的BLOG中,请看看怎么修改.
this.getRiskDutyFactorByPk(new Integer(baseChecked[i]))); 对它也进行说明,我们是在riskDutyService中增加了
//根据责任要素主键,取得一个责任要素对象,该方法避免了service调用service是的事务调用事务的问题
public Riskdutyfactor getRiskDutyFactorByPk(Integer id) {
return (Riskdutyfactor)this.getRiskDutyFactorDAO().getByPk(Riskdutyfactor.class,id);
}
方法直接调用RiskDutyFactorDAO中的方法,这样做的目的是避免了使用riskDutyService调用riskDutyFactorService.因此spring 中的配置文件修改为:
<!---->
请教高手!
xml 代码
<bean id="riskDutyService" parent="proxyTemplate"></bean>
-
- <bean id="riskDutyService" parent="proxyTemplate">
- <property name="target">
- <bean class="com.sleb.service.riskDuty.spring.RiskDutyServiceImpl">
- <property name="riskDutyDAO">
- <ref local="riskDutyDAO" />
- </property>
- <property name="riskDutyFactorDAO">
- <ref local="riskDutyFactorDAO" />
- </property>
- </bean>
- </property>
- </bean>
- <bean id="riskDutyDAO" class="com.sleb.dao.riskDuty.RiskDutyDAOImpl">
- <property name="sessionFactory">
- <ref bean="sessionFactory" />
- </property>
- </bean>
xml 代码
- <hibernate-mapping>
- <class name="com.sleb.po.Riskdutyfactor" table="RISKDUTYFACTOR" schema="XFLIU">
- <id name="riskdutyfactorid" type="integer">
- <column name="RISKDUTYFACTORID" />
- <generator class="sequence" >
- <param name="sequence">S_RISKDUTYFACTOR</param>
- </generator>
- </id>
- <property name="factorname" type="string">
- <column name="FACTORNAME" length="20" />
- </property>
- <property name="factorunit" type="string">
- <column name="FACTORUNIT" length="120" />
- </property>
- <property name="value" type="string">
- <column name="VALUE" length="120" />
- </property>
- <property name="sign" type="string">
- <column name="SIGN" length="1" />
- </property>
- <property name="language" type="string">
- <column name="LANGUAGE" length="1" />
- </property>
-
- <set name="riskduties" table="FACTORRISKDUTY" inverse="true" cascade="none">
- <key>
- <column name="RISKDUTYFACTORID" />
- </key>
- <many-to-many class="com.sleb.po.Riskduty" column="RISKDUTYID" />
- </set>
- </class>
- </hibernate-mapping>
<hibernate-mapping></hibernate-mapping>
java 代码
分享到:
评论
我在第一次操作的时候,可以增加的,但是等第2次操作的时候,就报以上错误.也就是不可能是你提到的一次处理过程中出现了多个session.
哪位大哥,可以给帮忙调试下,已经好久了,都弄不明白.谢谢!
2.执行sleb/crebas_db2.sql里的sql,生成数据库表
3.部署后先执行http://10.156.4.31:8090/sleb/riskDutyFactor/saveRiskDutyFactor.jsp,添加几个内容,后执行
http://10.156.4.31:8090/sleb/riskDuty/saveRiskDutyLink.jsp,点查询,后任意增加几个内容。第一次增加的时候不会报错,第2次就会出现错误。
所有日志如下:
13:22:14,061 INFO [PropertyMessageResources] Initializing, config='org.apache.struts.taglib.bean.LocalStrings', returnNull=true
13:22:14,139 INFO [PropertyMessageResources] Initializing, config='org.apache.struts.util.LocalStrings', returnNull=true
13:22:14,139 INFO [PropertyMessageResources] Initializing, config='org.apache.struts.taglib.html.LocalStrings', returnNull=true
13:22:14,155 INFO [PropertyMessageResources] Initializing, config='org.apache.struts.taglib.html.LocalStrings', returnNull=true
13:22:14,155 INFO [PropertyMessageResources] Initializing, config='org.apache.struts.taglib.html.LocalStrings', returnNull=true
13:22:14,155 INFO [PropertyMessageResources] Initializing, config='org.apache.struts.taglib.html.LocalStrings', returnNull=true
13:22:14,217 INFO [PropertyMessageResources] Initializing, config='org.apache.struts.taglib.html.LocalStrings', returnNull=true
13:22:14,217 INFO [PropertyMessageResources] Initializing, config='org.apache.struts.taglib.html.LocalStrings', returnNull=true
13:22:14,217 INFO [PropertyMessageResources] Initializing, config='org.apache.struts.taglib.html.LocalStrings', returnNull=true
13:22:14,217 INFO [PropertyMessageResources] Initializing, config='org.apache.struts.taglib.html.LocalStrings', returnNull=true
13:22:24,226 INFO [PropertyMessageResources] Initializing, config='org.apache.struts.actions.LocalStrings', returnNull=true
13:22:24,336 INFO [JdbcTransactionObjectSupport] JDBC 3.0 Savepoint class is available
13:22:24,508 INFO [XmlBeanDefinitionReader] Loading XML bean definitions from class path resource [org/springframework/jdbc/support/sql-error-codes.xml]
13:22:24,570 INFO [SQLErrorCodesFactory] SQLErrorCodes loaded: [DB2, HSQL, MS-SQL, MySQL, Oracle, Informix, PostgreSQL, Sybase]
13:22:24,820 INFO [STDOUT] Hibernate: select count(*) as col_0_0_ from XFLIU.RISKDUTYFACTOR riskdutyfa0_ where (riskdutyfa0_.FACTORNAME='保险期间' )
13:22:25,038 INFO [STDOUT] Hibernate: values nextval for S_RISKDUTYFACTOR
13:22:25,241 INFO [RiskDutyFactorDAOImpl] save successful
13:22:25,241 INFO [STDOUT] Hibernate: values nextval for S_RISKDUTYFACTOR
13:22:25,241 INFO [RiskDutyFactorDAOImpl] save successful
13:22:25,241 INFO [STDOUT] Hibernate: values nextval for S_RISKDUTYFACTOR
13:22:25,241 INFO [RiskDutyFactorDAOImpl] save successful
13:22:25,304 INFO [STDOUT] Hibernate: insert into XFLIU.RISKDUTYFACTOR (FACTORNAME, FACTORUNIT, VALUE, SIGN, LANGUAGE, RISKDUTYFACTORID) values (?, ?, ?, ?, ?, ?)
13:22:25,319 INFO [STDOUT] Hibernate: insert into XFLIU.RISKDUTYFACTOR (FACTORNAME, FACTORUNIT, VALUE, SIGN, LANGUAGE, RISKDUTYFACTORID) values (?, ?, ?, ?, ?, ?)
13:22:25,319 INFO [STDOUT] Hibernate: insert into XFLIU.RISKDUTYFACTOR (FACTORNAME, FACTORUNIT, VALUE, SIGN, LANGUAGE, RISKDUTYFACTORID) values (?, ?, ?, ?, ?, ?)
13:22:25,757 INFO [PropertyMessageResources] Initializing, config='org.apache.struts.taglib.bean.LocalStrings', returnNull=true
13:23:05,106 INFO [SaveRiskDutyFactorForm] factorUnitStr.length and factotValueStr.length are 0
13:23:05,121 INFO [STDOUT] Hibernate: select count(*) as col_0_0_ from XFLIU.RISKDUTYFACTOR riskdutyfa0_ where (riskdutyfa0_.FACTORNAME='费率' )
13:23:05,121 INFO [STDOUT] Hibernate: values nextval for S_RISKDUTYFACTOR
13:23:05,121 INFO [RiskDutyFactorDAOImpl] save successful
13:23:05,121 INFO [STDOUT] Hibernate: insert into XFLIU.RISKDUTYFACTOR (FACTORNAME, FACTORUNIT, VALUE, SIGN, LANGUAGE, RISKDUTYFACTORID) values (?, ?, ?, ?, ?, ?)
13:23:12,304 INFO [SaveRiskDutyFactorForm] factotValueStr.length is 0
13:23:12,335 INFO [STDOUT] Hibernate: select count(*) as col_0_0_ from XFLIU.RISKDUTYFACTOR riskdutyfa0_ where (riskdutyfa0_.FACTORNAME='计算方向' )
13:23:12,335 INFO [STDOUT] Hibernate: values nextval for S_RISKDUTYFACTOR
13:23:12,335 INFO [RiskDutyFactorDAOImpl] save successful
13:23:12,335 INFO [STDOUT] Hibernate: values nextval for S_RISKDUTYFACTOR
13:23:12,351 INFO [RiskDutyFactorDAOImpl] save successful
13:23:12,351 INFO [STDOUT] Hibernate: values nextval for S_RISKDUTYFACTOR
13:23:12,351 INFO [RiskDutyFactorDAOImpl] save successful
13:23:12,351 INFO [STDOUT] Hibernate: values nextval for S_RISKDUTYFACTOR
13:23:12,351 INFO [RiskDutyFactorDAOImpl] save successful
13:23:12,367 INFO [STDOUT] Hibernate: insert into XFLIU.RISKDUTYFACTOR (FACTORNAME, FACTORUNIT, VALUE, SIGN, LANGUAGE, RISKDUTYFACTORID) values (?, ?, ?, ?, ?, ?)
13:23:12,367 INFO [STDOUT] Hibernate: insert into XFLIU.RISKDUTYFACTOR (FACTORNAME, FACTORUNIT, VALUE, SIGN, LANGUAGE, RISKDUTYFACTORID) values (?, ?, ?, ?, ?, ?)
13:23:12,367 INFO [STDOUT] Hibernate: insert into XFLIU.RISKDUTYFACTOR (FACTORNAME, FACTORUNIT, VALUE, SIGN, LANGUAGE, RISKDUTYFACTORID) values (?, ?, ?, ?, ?, ?)
13:23:12,382 INFO [STDOUT] Hibernate: insert into XFLIU.RISKDUTYFACTOR (FACTORNAME, FACTORUNIT, VALUE, SIGN, LANGUAGE, RISKDUTYFACTORID) values (?, ?, ?, ?, ?, ?)
13:23:16,942 INFO [SaveRiskDutyFactorForm] factorUnitStr.length and factotValueStr.length are 0
13:23:16,957 INFO [STDOUT] Hibernate: select count(*) as col_0_0_ from XFLIU.RISKDUTYFACTOR riskdutyfa0_ where (riskdutyfa0_.FACTORNAME='免赔额' )
13:23:16,973 INFO [STDOUT] Hibernate: values nextval for S_RISKDUTYFACTOR
13:23:16,973 INFO [RiskDutyFactorDAOImpl] save successful
13:23:16,973 INFO [STDOUT] Hibernate: insert into XFLIU.RISKDUTYFACTOR (FACTORNAME, FACTORUNIT, VALUE, SIGN, LANGUAGE, RISKDUTYFACTORID) values (?, ?, ?, ?, ?, ?)
13:23:20,830 INFO [SaveRiskDutyFactorForm] factorUnitStr.length and factotValueStr.length are 0
13:23:20,861 INFO [STDOUT] Hibernate: select count(*) as col_0_0_ from XFLIU.RISKDUTYFACTOR riskdutyfa0_ where (riskdutyfa0_.FACTORNAME='赔付比例' )
13:23:20,861 INFO [STDOUT] Hibernate: values nextval for S_RISKDUTYFACTOR
13:23:20,861 INFO [RiskDutyFactorDAOImpl] save successful
13:23:20,877 INFO [STDOUT] Hibernate: insert into XFLIU.RISKDUTYFACTOR (FACTORNAME, FACTORUNIT, VALUE, SIGN, LANGUAGE, RISKDUTYFACTORID) values (?, ?, ?, ?, ?, ?)
13:23:26,248 INFO [SaveRiskDutyFactorForm] factorUnitStr.length and factotValueStr.length are 0
13:23:26,279 INFO [STDOUT] Hibernate: select count(*) as col_0_0_ from XFLIU.RISKDUTYFACTOR riskdutyfa0_ where (riskdutyfa0_.FACTORNAME='住院期间' )
13:23:26,279 INFO [STDOUT] Hibernate: values nextval for S_RISKDUTYFACTOR
13:23:26,279 INFO [RiskDutyFactorDAOImpl] save successful
13:23:26,295 INFO [STDOUT] Hibernate: insert into XFLIU.RISKDUTYFACTOR (FACTORNAME, FACTORUNIT, VALUE, SIGN, LANGUAGE, RISKDUTYFACTORID) values (?, ?, ?, ?, ?, ?)
13:23:34,867 INFO [PropertyMessageResources] Initializing, config='org.apache.struts.taglib.logic.LocalStrings', returnNull=true
13:23:36,725 INFO [PropertyMessageResources] Initializing, config='org.apache.struts.taglib.html.LocalStrings', returnNull=true
13:25:05,542 INFO [STDOUT] Hibernate: select riskdutyfa0_.RISKDUTYFACTORID as RISKDUTY1_, riskdutyfa0_.FACTORNAME as FACTORNAME0_, riskdutyfa0_.FACTORUNIT as FACTORUNIT0_, riskdutyfa0_.VALUE as VALUE0_, riskdutyfa0_.SIGN as SIGN0_, riskdutyfa0_.LANGUAGE as LANGUAGE0_ from XFLIU.RISKDUTYFACTOR riskdutyfa0_ where (riskdutyfa0_.SIGN='0' )
13:25:05,604 INFO [STDOUT] Hibernate: select riskdutyfa0_.RISKDUTYFACTORID as RISKDUTY1_, riskdutyfa0_.FACTORNAME as FACTORNAME0_, riskdutyfa0_.FACTORUNIT as FACTORUNIT0_, riskdutyfa0_.VALUE as VALUE0_, riskdutyfa0_.SIGN as SIGN0_, riskdutyfa0_.LANGUAGE as LANGUAGE0_ from XFLIU.RISKDUTYFACTOR riskdutyfa0_ where (riskdutyfa0_.SIGN='0' )
13:25:05,604 INFO [STDOUT] false
13:25:05,636 INFO [STDOUT] Hibernate: select riskdutyfa0_.RISKDUTYFACTORID as RISKDUTY1_, riskdutyfa0_.FACTORNAME as FACTORNAME0_, riskdutyfa0_.FACTORUNIT as FACTORUNIT0_, riskdutyfa0_.VALUE as VALUE0_, riskdutyfa0_.SIGN as SIGN0_, riskdutyfa0_.LANGUAGE as LANGUAGE0_ from XFLIU.RISKDUTYFACTOR riskdutyfa0_ where (riskdutyfa0_.SIGN='1' )
13:25:05,667 INFO [STDOUT] Hibernate: select riskdutyfa0_.RISKDUTYFACTORID as RISKDUTY1_, riskdutyfa0_.FACTORNAME as FACTORNAME0_, riskdutyfa0_.FACTORUNIT as FACTORUNIT0_, riskdutyfa0_.VALUE as VALUE0_, riskdutyfa0_.SIGN as SIGN0_, riskdutyfa0_.LANGUAGE as LANGUAGE0_ from XFLIU.RISKDUTYFACTOR riskdutyfa0_ where (riskdutyfa0_.SIGN='1' )
13:25:05,667 INFO [STDOUT] false
13:25:05,698 INFO [PropertyMessageResources] Initializing, config='org.apache.struts.taglib.logic.LocalStrings', returnNull=true
13:25:05,714 INFO [PropertyMessageResources] Initializing, config='org.apache.struts.taglib.html.LocalStrings', returnNull=true
13:27:47,029 INFO [STDOUT] Hibernate: select count(*) as col_0_0_ from XFLIU.RISKDUTY riskduty0_ where (riskduty0_.DUTYNAME='公共交通意外伤害' )
13:27:47,076 INFO [STDOUT] Hibernate: select riskdutyfa0_.RISKDUTYFACTORID as RISKDUTY1_0_, riskdutyfa0_.FACTORNAME as FACTORNAME0_0_, riskdutyfa0_.FACTORUNIT as FACTORUNIT0_0_, riskdutyfa0_.VALUE as VALUE0_0_, riskdutyfa0_.SIGN as SIGN0_0_, riskdutyfa0_.LANGUAGE as LANGUAGE0_0_ from XFLIU.RISKDUTYFACTOR riskdutyfa0_ where riskdutyfa0_.RISKDUTYFACTORID=?
13:27:47,123 INFO [RiskDutyServiceImpl] 保险期间
13:27:47,123 INFO [STDOUT] Hibernate: select riskdutyfa0_.RISKDUTYFACTORID as RISKDUTY1_0_, riskdutyfa0_.FACTORNAME as FACTORNAME0_0_, riskdutyfa0_.FACTORUNIT as FACTORUNIT0_0_, riskdutyfa0_.VALUE as VALUE0_0_, riskdutyfa0_.SIGN as SIGN0_0_, riskdutyfa0_.LANGUAGE as LANGUAGE0_0_ from XFLIU.RISKDUTYFACTOR riskdutyfa0_ where riskdutyfa0_.RISKDUTYFACTORID=?
13:27:47,138 INFO [RiskDutyServiceImpl] 计算方向
13:27:47,138 INFO [STDOUT] Hibernate: select riskdutyfa0_.RISKDUTYFACTORID as RISKDUTY1_0_, riskdutyfa0_.FACTORNAME as FACTORNAME0_0_, riskdutyfa0_.FACTORUNIT as FACTORUNIT0_0_, riskdutyfa0_.VALUE as VALUE0_0_, riskdutyfa0_.SIGN as SIGN0_0_, riskdutyfa0_.LANGUAGE as LANGUAGE0_0_ from XFLIU.RISKDUTYFACTOR riskdutyfa0_ where riskdutyfa0_.RISKDUTYFACTORID=?
13:27:47,154 INFO [RiskDutyServiceImpl] 费率
13:27:47,154 INFO [RiskDutyServiceImpl] begin save complexCheck riskDuty
13:27:47,154 INFO [STDOUT] Hibernate: values nextval for S_RISKDUTY
13:27:47,154 INFO [RiskDutyDAOImpl] save successful
13:27:47,170 INFO [STDOUT] Hibernate: insert into XFLIU.RISKDUTY (DUTYNAME, DUTYTYPE, LANGUAGE, RISKDUTYID) values (?, ?, ?, ?)
13:27:47,185 INFO [STDOUT] Hibernate: insert into FACTORRISKDUTY (RISKDUTYID, RISKDUTYFACTORID) values (?, ?)
13:27:47,997 INFO [STDOUT] Hibernate: insert into FACTORRISKDUTY (RISKDUTYID, RISKDUTYFACTORID) values (?, ?)
13:27:47,997 INFO [STDOUT] Hibernate: insert into FACTORRISKDUTY (RISKDUTYID, RISKDUTYFACTORID) values (?, ?)
13:27:48,028 INFO [STDOUT] Hibernate: select riskdutyfa0_.RISKDUTYFACTORID as RISKDUTY1_, riskdutyfa0_.FACTORNAME as FACTORNAME0_, riskdutyfa0_.FACTORUNIT as FACTORUNIT0_, riskdutyfa0_.VALUE as VALUE0_, riskdutyfa0_.SIGN as SIGN0_, riskdutyfa0_.LANGUAGE as LANGUAGE0_ from XFLIU.RISKDUTYFACTOR riskdutyfa0_ where (riskdutyfa0_.SIGN='0' )
13:27:48,044 INFO [STDOUT] Hibernate: select riskdutyfa0_.RISKDUTYFACTORID as RISKDUTY1_, riskdutyfa0_.FACTORNAME as FACTORNAME0_, riskdutyfa0_.FACTORUNIT as FACTORUNIT0_, riskdutyfa0_.VALUE as VALUE0_, riskdutyfa0_.SIGN as SIGN0_, riskdutyfa0_.LANGUAGE as LANGUAGE0_ from XFLIU.RISKDUTYFACTOR riskdutyfa0_ where (riskdutyfa0_.SIGN='0' )
13:27:48,044 INFO [STDOUT] false
13:27:48,075 INFO [STDOUT] Hibernate: select riskdutyfa0_.RISKDUTYFACTORID as RISKDUTY1_, riskdutyfa0_.FACTORNAME as FACTORNAME0_, riskdutyfa0_.FACTORUNIT as FACTORUNIT0_, riskdutyfa0_.VALUE as VALUE0_, riskdutyfa0_.SIGN as SIGN0_, riskdutyfa0_.LANGUAGE as LANGUAGE0_ from XFLIU.RISKDUTYFACTOR riskdutyfa0_ where (riskdutyfa0_.SIGN='1' )
13:27:48,075 INFO [STDOUT] Hibernate: select riskdutyfa0_.RISKDUTYFACTORID as RISKDUTY1_, riskdutyfa0_.FACTORNAME as FACTORNAME0_, riskdutyfa0_.FACTORUNIT as FACTORUNIT0_, riskdutyfa0_.VALUE as VALUE0_, riskdutyfa0_.SIGN as SIGN0_, riskdutyfa0_.LANGUAGE as LANGUAGE0_ from XFLIU.RISKDUTYFACTOR riskdutyfa0_ where (riskdutyfa0_.SIGN='1' )
13:27:48,091 INFO [STDOUT] false
13:28:11,263 INFO [STDOUT] Hibernate: select count(*) as col_0_0_ from XFLIU.RISKDUTY riskduty0_ where (riskduty0_.DUTYNAME='意外死亡' )
13:28:11,279 INFO [STDOUT] Hibernate: select riskdutyfa0_.RISKDUTYFACTORID as RISKDUTY1_0_, riskdutyfa0_.FACTORNAME as FACTORNAME0_0_, riskdutyfa0_.FACTORUNIT as FACTORUNIT0_0_, riskdutyfa0_.VALUE as VALUE0_0_, riskdutyfa0_.SIGN as SIGN0_0_, riskdutyfa0_.LANGUAGE as LANGUAGE0_0_ from XFLIU.RISKDUTYFACTOR riskdutyfa0_ where riskdutyfa0_.RISKDUTYFACTORID=?
13:28:11,279 INFO [RiskDutyServiceImpl] 保险期间
13:28:11,279 INFO [STDOUT] Hibernate: select riskdutyfa0_.RISKDUTYFACTORID as RISKDUTY1_0_, riskdutyfa0_.FACTORNAME as FACTORNAME0_0_, riskdutyfa0_.FACTORUNIT as FACTORUNIT0_0_, riskdutyfa0_.VALUE as VALUE0_0_, riskdutyfa0_.SIGN as SIGN0_0_, riskdutyfa0_.LANGUAGE as LANGUAGE0_0_ from XFLIU.RISKDUTYFACTOR riskdutyfa0_ where riskdutyfa0_.RISKDUTYFACTORID=?
13:28:11,294 INFO [RiskDutyServiceImpl] 计算方向
13:28:11,294 INFO [STDOUT] Hibernate: select riskdutyfa0_.RISKDUTYFACTORID as RISKDUTY1_0_, riskdutyfa0_.FACTORNAME as FACTORNAME0_0_, riskdutyfa0_.FACTORUNIT as FACTORUNIT0_0_, riskdutyfa0_.VALUE as VALUE0_0_, riskdutyfa0_.SIGN as SIGN0_0_, riskdutyfa0_.LANGUAGE as LANGUAGE0_0_ from XFLIU.RISKDUTYFACTOR riskdutyfa0_ where riskdutyfa0_.RISKDUTYFACTORID=?
13:28:11,294 INFO [RiskDutyServiceImpl] 费率
13:28:11,294 INFO [RiskDutyServiceImpl] begin save complexCheck riskDuty
13:28:11,294 INFO [STDOUT] Hibernate: values nextval for S_RISKDUTY
13:28:11,310 ERROR [RiskDutyDAOImpl] save failed
org.springframework.orm.hibernate3.HibernateSystemException: a different object with the same identifier value was already associated with the session: [com.sleb.po.Riskdutyfactor#5]; nested exception is org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session: [com.sleb.po.Riskdutyfactor#5]
org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session: [com.sleb.po.Riskdutyfactor#5]
at org.hibernate.engine.PersistenceContext.checkUniqueness(PersistenceContext.java:586)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performUpdate(DefaultSaveOrUpdateEventListener.java:254)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsDetached(DefaultSaveOrUpdateEventListener.java:214)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:91)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:69)
at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:468)
at org.hibernate.engine.Cascades$5.cascade(Cascades.java:154)
at org.hibernate.engine.Cascades.cascadeAssociation(Cascades.java:771)
at org.hibernate.engine.Cascades.cascade(Cascades.java:720)
at org.hibernate.engine.Cascades.cascadeCollection(Cascades.java:895)
at org.hibernate.engine.Cascades.cascadeAssociation(Cascades.java:792)
at org.hibernate.engine.Cascades.cascade(Cascades.java:720)
at org.hibernate.engine.Cascades.cascade(Cascades.java:847)
at org.hibernate.event.def.AbstractSaveEventListener.cascadeAfterSave(AbstractSaveEventListener.java:363)
at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:265)
at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:160)
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:108)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:184)
at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:33)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:173)
at org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:27)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:69)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:481)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:476)
at org.springframework.orm.hibernate3.HibernateTemplate$12.doInHibernate(HibernateTemplate.java:615)
at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:365)
at org.springframework.orm.hibernate3.HibernateTemplate.save(HibernateTemplate.java:612)
at com.sleb.dao.base.BaseDao.save(BaseDao.java:100)
at com.sleb.service.riskDuty.spring.RiskDutyServiceImpl.saveRiskduty(RiskDutyServiceImpl.java:56)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:335)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:181)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:148)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:170)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:176)
at $Proxy47.saveRiskduty(Unknown Source)
at com.sleb.struts.action.riskDuty.SaveRiskDutyAction.save(SaveRiskDutyAction.java:92)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:280)
at org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:216)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at com.sleb.util.filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:74)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:186)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:174)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:186)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:75)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:186)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:44)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:169)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
at java.lang.Thread.run(Thread.java:534)
13:28:11,388 WARN [RequestProcessor] Unhandled Exception thrown: class org.springframework.orm.hibernate3.HibernateSystemException
13:28:11,435 ERROR [Engine] StandardWrapperValve[action]: Servlet.service() for servlet action threw exception
org.springframework.orm.hibernate3.HibernateSystemException: a different object with the same identifier value was already associated with the session: [com.sleb.po.Riskdutyfactor#5]; nested exception is org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session: [com.sleb.po.Riskdutyfactor#5]
org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session: [com.sleb.po.Riskdutyfactor#5]
at org.hibernate.engine.PersistenceContext.checkUniqueness(PersistenceContext.java:586)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performUpdate(DefaultSaveOrUpdateEventListener.java:254)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsDetached(DefaultSaveOrUpdateEventListener.java:214)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:91)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:69)
at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:468)
at org.hibernate.engine.Cascades$5.cascade(Cascades.java:154)
at org.hibernate.engine.Cascades.cascadeAssociation(Cascades.java:771)
at org.hibernate.engine.Cascades.cascade(Cascades.java:720)
at org.hibernate.engine.Cascades.cascadeCollection(Cascades.java:895)
at org.hibernate.engine.Cascades.cascadeAssociation(Cascades.java:792)
at org.hibernate.engine.Cascades.cascade(Cascades.java:720)
at org.hibernate.engine.Cascades.cascade(Cascades.java:847)
at org.hibernate.event.def.AbstractSaveEventListener.cascadeAfterSave(AbstractSaveEventListener.java:363)
at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:265)
at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:160)
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:108)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:184)
at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:33)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:173)
at org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:27)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:69)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:481)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:476)
at org.springframework.orm.hibernate3.HibernateTemplate$12.doInHibernate(HibernateTemplate.java:615)
at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:365)
at org.springframework.orm.hibernate3.HibernateTemplate.save(HibernateTemplate.java:612)
at com.sleb.dao.base.BaseDao.save(BaseDao.java:100)
at com.sleb.service.riskDuty.spring.RiskDutyServiceImpl.saveRiskduty(RiskDutyServiceImpl.java:56)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:335)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:181)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:148)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:170)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:176)
at $Proxy47.saveRiskduty(Unknown Source)
at com.sleb.struts.action.riskDuty.SaveRiskDutyAction.save(SaveRiskDutyAction.java:92)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:280)
at org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:216)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at com.sleb.util.filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:74)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:186)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:174)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:186)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:75)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:186)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:44)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:169)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
at java.lang.Thread.run(Thread.java:534)
Userinfo user = (Userinfo)this.getObject(Userinfo.class, new Long(5))
时是一个session,而在
String sql = "select user from User user";
List list = this.getByHqlList(sql);
最后:
user.set***();
this.update();
时是另一个session,可以调试看看是不是同一个session。
首先查询id为5的User对象 .
Userinfo user = (Userinfo)this.getObject(Userinfo.class, new Long(5))
再执行一个查询
String sql = "select user from User user";
List list = this.getByHqlList(sql);
最后:
user.set***();
this.update();
//居然有问题??? 我改成先session.clear()再update,通过!!
//以上是我简化了实际业务的情况,遇到和楼主同样的错!
//难道这样写法不行??? 望指教!!!
楼上说:“一个session中如果关联了或者说缓存了一个对象,当你将另一个相同id的游离对象与该session关联起来时会报那个错误。”
这里有个疑问:为什么会出现“一个相同id的游离对象”。如果取这条数据的持久化对象,不论从session取还是查数据库只有一个,怎么就会出现“一个相同id的游离对象”?
一个session中如果关联了或者说缓存了一个对象,当你将另一个相同id的游离对象与该session关联起来时会报那个错误。
我现在手头上没有代码了,等回来后,把代码打包,发上来,希望大家能批评一下。
对于第一种方法,我忘记试过没有,不过我会尝试下的,但是我试过将清空Session放在save()后做过,结果是没有对数据库进行操作。
也在riskDuty.setDutyname(dutyName);前加过,没有什么效果,执行了,但是还是报同样的错。
merge()也尝试了,不过好象还不太会用。我DAO里的save()是save()方法,不是saveOrUpdate().
可能我那里还是有问题的,春节过后,我把代码整理下,发给你,你帮忙给我看看吧,现在我没有代码,放在公司了,我已经请假回家了!
谢谢!顺便祝看我帖子的人新年快乐!
先用你注释掉的那行代码在save()动作之前清空Session看看行不行:
又或者尝试一下以merge()方法来完成持久化(这样应该就不会因为cascade="save-update"而触动到关联的集合端):
另外问一下,你的DAO里面的save()用的是Session的saveOrUpdate()方法吗?
我是多对多的,但是riskdutyfactor表已经有数据了,后再对riskduty进行操作,如果都修改为inverse="true",那没有对象来维护中间表了.
不知道我说的对不对.
你说的代码可读性不好,是因为我注释少,还是我说的不清楚呢?希望能说的直白点,呵呵,学习ING.
对于出错的问题,我知道是这两个String[] baseChecked, String[] complexChecked造成的,但是怎么修改呢?
另外,根据你的这段代码所体现的逻辑关系,建议将这个Set集合也设置inverse="true"。
我觉得你这里出现问题的原因并不在于是否采用merge()方法来持久化PO……
况且你对merge()的用法也是不对的,它的正确用法请参考API文档。
Session.merge() API doc:
http://www.hibernate.org/hib_docs/v3/api/org/hibernate/Session.html#merge(java.lang.Object)
程序增加了两行,但是还是不对,不知道merge怎么用.
我在网络上搜到过,但是能不能帮我详细的看下我的代码,应该将你说的meger()方法放在那里?谢谢!
http://www.hibernate.org/116.html#A8
这个异常估计是每一个Hibernate使用者都曾经遇到过的……
这样的帖子建议放到新手区。
发表代码请用code包含。BBCODE模式下,用Code包含, RichEdit模式下用代码输入窗口输入代码。