<set name="boabiaoinfo" cascade="all" lazy="false" inverse="true" order-by="weizhi asc">
<key column="bid" not-null="false"></key>
<one-to-many class="com.lhkj.data.po.Customerbaobiaoinfo" />
</set>
更新主表时set集合的数据不是更新的,而是添加了新数据
<key column="bid" not-null="false"></key>
<one-to-many class="com.lhkj.data.po.Customerbaobiaoinfo" />
</set>
更新主表时set集合的数据不是更新的,而是添加了新数据
解决方案 »
- java.lang.RuntimeException: Invalid action class configuration that references a
- 请教:java.sql.SQLException: No suitable driver found for jdbc:mysql//localhost/tes
- jmf是否可以得到摄像头设备名
- get方式传控件值
- jsp论坛的帖子问题??
- 关于checkbox的初始化
- 求助!!请高手指点!(有时提示“无效的游标错误!”)
- 求教struts1.2+spring2.0+hibernate3.0启动报错,请高人指点一下
- +++++++++++++++++++++++一个字闷!!!!++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- 各位高手,小弟正在配置JSP运行环境,可是怎么也配置不成功!求教!!!谢谢!帮助者必有分!
- 关于多附件上传的问题
- 只使用struts2标签能不能实现数据分页显示.
删除时可以级联删除,但是更新时,原来从表内的数据没有删除,而是新加了记录
column="bid"
unique="true"
not-null="false" lazy="false"/>
是啊
那该什么弄啊
请指教一下!
谢谢
你想要什么效果啊?cascade不是非要设置成all的
是不是配置文件哪里有问题啊
or
<many-to-one
update="true"
......
/>
Customerbaobiao.hbm.xml
<set name="boabiaoinfo" cascade="all" lazy="false" inverse="false" order-by="weizhi asc">
<key column="bid" not-null="false"></key>
<one-to-many class="com.lhkj.data.po.Customerbaobiaoinfo" />
</set>Customerbaobiaoinfo.hbm.xml
<many-to-one name="customerbaobiao"
column="bid"
unique="true"
not-null="false" />看看这两个配置文件有什么不妥的
后台得到对象并更新对象的代码
Customerbaobiao baobiao = new Customerbaobiao();
if(baobiaoid!=null&&!baobiaoid.equals(""))
{
baobiao=this.myservice.findById(Customerbaobiao.class, Integer.parseInt(baobiaoid));
}
baobiao.setBaobiaoname(title);
baobiao.setType(type);
Set<Customerbaobiaoinfo> baobiaoinfoset = baobiao.getBoabiaoinfo();
for(String s : baobiaoinfos)
{
String [] bao = s.split("-");
Customerbaobiaoinfo bf = new Customerbaobiaoinfo();
try{
bf.setTablename(bao[0]);
bf.setColumntype(Integer.valueOf(bao[1]));
bf.setDatatype(Integer.valueOf(bao[2]));
bf.setColumnstr(bao[3]);
bf.setDisplayname(bao[4]);
bf.setWeizhi(Integer.valueOf(bao[5]));
}catch(Exception e)
{
e.printStackTrace();
}
//建立两表的关系
bf.setCustomerbaobiao(baobiao);
baobiaoinfoset.add(bf);
}
baobiao.setBoabiaoinfo(baobiaoinfoset);
if(baobiaoid!=null&&!baobiaoid.equals(""))
{
baobiao=this.myservice.findById(Customerbaobiao.class, Integer.parseInt(baobiaoid));
}
baobiao.setBaobiaoname(title);
baobiao.setType(type); //断开关系 注:关系由多方维护 如一方维护还简单点
Set<Customerbaobaobiaoinfo> infos = baobiao.get***() //具体用你定义获得Customerbaobiaoinfo对象集合的方法
for(Customerbaobiaoinfo info : infos){
info.setCustomerbaobiao(null);
} //下面代码不变
Set <Customerbaobiaoinfo> baobiaoinfoset = baobiao.getBoabiaoinfo();
for(String s : baobiaoinfos)
{
String [] bao = s.split("-");
Customerbaobiaoinfo bf = new Customerbaobiaoinfo();
try{
bf.setTablename(bao[0]);
bf.setColumntype(Integer.valueOf(bao[1]));
bf.setDatatype(Integer.valueOf(bao[2]));
bf.setColumnstr(bao[3]);
bf.setDisplayname(bao[4]);
bf.setWeizhi(Integer.valueOf(bao[5]));
}catch(Exception e)
{
e.printStackTrace();
}
//建立两表的关系
bf.setCustomerbaobiao(baobiao);
baobiaoinfoset.add(bf);
}
baobiao.setBoabiaoinfo(baobiaoinfoset);
如搞不定,发邮件:yanjun◎linktrust.com.cn