论坛首页 入门技术论坛

解析邮箱中的附件

浏览 1764 次
该帖已经被评为新手帖
作者 正文
   发表时间:2008-01-22   最后修改:2010-07-30
public boolean updateDevice(Long deviceCode, Long deviceType, Long operType, String system_id) {
final String hsql = "from DeviceInfo info where info.deviceCode=? and info.deviceType=? and info.system_id=?";
final Long code = deviceCode;
final Long type = deviceType;
final Long oper = operType;
final String systemId = system_id;
Boolean result = false;
try {
result = (Boolean) getHibernateTemplate().execute(
new HibernateCallback() {
@SuppressWarnings("unchecked")
public Object doInHibernate(Session session)
throws HibernateException, SQLException {
Query query = session.createQuery(hsql);
query.setLong(0, code);
query.setLong(1, type);
query.setString(2, systemId);

List<DeviceInfo> list = query.list();
if (list == null || list.size() <= 0) {
return false;
}
DeviceInfo toMergeItem = list.get(0);
toMergeItem.setUserFlag(oper);
if (logger.isDebugEnabled()) {
logger.debug("save DeviceInfo item: " + toMergeItem);
}
// 保存或更新version
session.merge(toMergeItem);
// 提交变更
session.flush();
return true;
}
});
} catch (Exception e) {
log.error(e.getStackTrace());
}
return result;
}


论坛首页 入门技术版

跳转论坛:
Global site tag (gtag.js) - Google Analytics