hibernate 级联更新时 为什么只能更新一个表,而另外一个表是直接插入了数据。。并没有更新。谁知道是为什么
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!--
Mapping file autogenerated by MyEclipse Persistence Tools
-->
<hibernate-mapping>
<class name="com.accp.entity.VoteOption" table="VOTE_OPTION">
<id name="id" type="java.lang.Short">
<column name="VO_ID"/>
<generator class="sequence">
<param name="sequence">vote_seq</param>
</generator>
</id>
<property name="option" type="java.lang.String">
<column name="VO_OPTION" length="10" not-null="true"/>
</property>
<many-to-one name="subject" class="com.accp.entity.VoteSubject" lazy="false" cascade="all">
<column name="VS_ID"></column>
</many-to-one>
</class>
</hibernate-mapping>
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!--
Mapping file autogenerated by MyEclipse Persistence Tools
-->
<hibernate-mapping>
<class name="com.accp.entity.VoteSubject" table="VOTE_SUBJECT">
<id name="id" type="java.lang.Integer">
<column name="ID"/>
<generator class="sequence">
<param name="sequence">vote_seq</param>
</generator>
</id>
<property name="title" type="java.lang.String">
<column name="VS_TITLE" length="10" not-null="true"/>
</property>
<property name="type" type="java.lang.Short">
<column name="VS_TYPE" length="10" not-null="true"/>
</property>
<set name="option" table="VOTE_OPTION" cascade="all" inverse="true" lazy="false">
<key>
<column name="VS_ID"></column>
</key>
<one-to-many class="com.accp.entity.VoteOption"/>
</set>
</class>
</hibernate-mapping>
我这两个表是配置的双向关联 。。一对多 和 多对一 关联。也设置了级联 。
Hibernate: insert into VOTE_OPTION (VO_OPTION, VS_ID, VO_ID) values (?, ?, ?)
Hibernate: insert into VOTE_OPTION (VO_OPTION, VS_ID, VO_ID) values (?, ?, ?)
Hibernate: insert into VOTE_OPTION (VO_OPTION, VS_ID, VO_ID) values (?, ?, ?)
Hibernate: insert into VOTE_OPTION (VO_OPTION, VS_ID, VO_ID) values (?, ?, ?)
Hibernate: insert into VOTE_OPTION (VO_OPTION, VS_ID, VO_ID) values (?, ?, ?)
Hibernate: insert into VOTE_OPTION (VO_OPTION, VS_ID, VO_ID) values (?, ?, ?)
Hibernate: insert into VOTE_OPTION (VO_OPTION, VS_ID, VO_ID) values (?, ?, ?)
Hibernate: insert into VOTE_OPTION (VO_OPTION, VS_ID, VO_ID) values (?, ?, ?)
Hibernate: insert into VOTE_OPTION (VO_OPTION, VS_ID, VO_ID) values (?, ?, ?)
Hibernate: insert into VOTE_OPTION (VO_OPTION, VS_ID, VO_ID) values (?, ?, ?)
Hibernate: insert into VOTE_OPTION (VO_OPTION, VS_ID, VO_ID) values (?, ?, ?)
Hibernate: insert into VOTE_OPTION (VO_OPTION, VS_ID, VO_ID) values (?, ?, ?)
Hibernate: insert into VOTE_OPTION (VO_OPTION, VS_ID, VO_ID) values (?, ?, ?)
Hibernate: insert into VOTE_OPTION (VO_OPTION, VS_ID, VO_ID) values (?, ?, ?)
Hibernate: insert into VOTE_OPTION (VO_OPTION, VS_ID, VO_ID) values (?, ?, ?)
Hibernate: insert into VOTE_OPTION (VO_OPTION, VS_ID, VO_ID) values (?, ?, ?)
Hibernate: insert into VOTE_OPTION (VO_OPTION, VS_ID, VO_ID) values (?, ?, ?)
Hibernate: update VOTE_SUBJECT set VS_TITLE=?, VS_TYPE=? where ID=?
控制台 只 输出了一条 update语句
public String updateVoteSubject(){ //更新投票内容
int id = Integer.parseInt(ServletActionContext.
getRequest().getParameter("SubjectId"));
VoteSubject subject = new VoteSubject();
subject.setId(id);
subject.setTitle(this.subject.getTitle());
subject.setType(new Short(this.subject.getType()));
for(int i = 0; i<options.length; i++){
VoteOption option = new VoteOption();
option.setOption(options[i]);
option.setSubject(subject);
subject.getOption().add(option);
}
new VoteSubjectDaoImpl().voteUpdate(subject);
return "update";
}