您的位置:首页 > 其它

保存bean时,对bean中的外键对象需要判断fkbean的fkid是否为空

2012-06-05 22:46 288 查看
保存bean时,对bean中的外键对象需要判断fkbean的fkid是否为空,fkbean不为空,但是fkid为空,则无法实现用this.getHibernateTemplate().save(object);保存记录。

public String saveOrupdate(String type){
String succ = "success";
if(spool != null && spool.getId()!=null){
type = "update";
}
if(spool.getArea()!=null && spool.getArea().getId()==null){
spool.setArea(null);
}
if(spool.getOldSpool()!=null && spool.getOldSpool().getId()==null){
spool.setOldSpool(null);
}
if(spool.getTrment()!=null && spool.getTrment().getId()==null){
spool.setTrment(null);
}
if(type.equalsIgnoreCase("save")){
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: