现在有一个大的页面,里面有一些有很多提交按钮我现在每点一次提交按钮,通过anction 提交一次,把数据存到httpsession里面最后我点保存按钮才把刚才所有提交的数据 保存主表时与它关联的(多的一方)数据库全部保存我是这么写的
if (session.getAttribute("strategy") == null) {
strategy = new Strategy();
} else {
strategy = (Strategy) session.getAttribute("strategy");
}
timesRule.setStrategy(strategy);
strategy.setTimesRule(strategy.getTimesRule());
strategy.getTimesRule().add(timesRule);
session.setAttribute("strategy", strategy);
如下配置strategy类
private Integer nmId;
private Set <TimesRule> timesRule ; hbm.xml
<set name="TimesRule" inverse="true" cascade="all" >
<key column="nmStrategyId"/>
<one-to-many class="TimesRule"/>
</set>
timesRule类
private int nmId;
private int nmStrategyId;
private Strategy strategy; hbm.xml
<many-to-one name="strategy" column="nmStrategyId" cascade="all" /> 现在实现不了
问这么能合理的实现存主表,子表也存储的功能
if (session.getAttribute("strategy") == null) {
strategy = new Strategy();
} else {
strategy = (Strategy) session.getAttribute("strategy");
}
timesRule.setStrategy(strategy);
strategy.setTimesRule(strategy.getTimesRule());
strategy.getTimesRule().add(timesRule);
session.setAttribute("strategy", strategy);
如下配置strategy类
private Integer nmId;
private Set <TimesRule> timesRule ; hbm.xml
<set name="TimesRule" inverse="true" cascade="all" >
<key column="nmStrategyId"/>
<one-to-many class="TimesRule"/>
</set>
timesRule类
private int nmId;
private int nmStrategyId;
private Strategy strategy; hbm.xml
<many-to-one name="strategy" column="nmStrategyId" cascade="all" /> 现在实现不了
问这么能合理的实现存主表,子表也存储的功能
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货