Hibernate执行批量添加时,不知道怎么了在数据库中只添加了一行数据,求大神指教,代码如下:
List<Manager>manger=managerMng.getAll();for(inti=0;i<manger.size();i++){Managermang=n...
List<Manager> manger = managerMng.getAll();
for(int i = 0;i<manger.size();i++){
Manager mang=new Manager();
mang = manger.get(i);
bean.setManager(mang);
bean = ordMng.save(bean);
}
return addOrder( request, model);
这是Hibernate配置文件
<id name="id" type="java.lang.Integer" column="id"><generator class="identity"/></id>
<property name="title" column="title" type="string"/>
<property name="content" column="content" type="string"/>
<property name="author" column="author" type="string"/>
<property name="releaseTime" column="releaseTime" type="timestamp"/>
<many-to-one name="manager" column="tt_manager_id" cascade="save-update" class="Manager" />
</class> 展开
for(int i = 0;i<manger.size();i++){
Manager mang=new Manager();
mang = manger.get(i);
bean.setManager(mang);
bean = ordMng.save(bean);
}
return addOrder( request, model);
这是Hibernate配置文件
<id name="id" type="java.lang.Integer" column="id"><generator class="identity"/></id>
<property name="title" column="title" type="string"/>
<property name="content" column="content" type="string"/>
<property name="author" column="author" type="string"/>
<property name="releaseTime" column="releaseTime" type="timestamp"/>
<many-to-one name="manager" column="tt_manager_id" cascade="save-update" class="Manager" />
</class> 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询