package com.bean;
import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.LockMode;
import org.hibernate.Query;
import org.hibernate.criterion.Example;
/**
* A data access object (DAO) providing persistence and search support for Agent
* entities. Transaction control of the save(), update() and delete() operations
* can directly support Spring container-managed transactions or they can be
* augmented to handle user-managed Spring transactions. Each of these methods
* provides additional information for how to configure it for the desired type
* of transaction control.
*
* @see com.bean.Agent
* @author MyEclipse Persistence Tools
*/
public class AgentDAO extends BaseHibernateDAO {
private static final Log log = LogFactory.getLog(AgentDAO.class);
// property constants
public static final String AGENT_ID = "agentId";
public static final String PARENT_ID = "parentId";
public static final String LEVEL = "level";
public static final String USER_NAME = "userName";
public static final String USER_PASS = "userPass";
public static final String STATUS = "status";
public static final String NAME = "name";
public void save(Agent transientInstance) {
log.debug("saving Agent instance");
try {
getSession().save(transientInstance);
log.debug("save successful");
} catch (RuntimeException re) {
log.error("save failed", re);
throw re;
}
}
/***************************************************************************
* 登录查询
**************************************************************************/
public List getlogin(String userName, String password) {
this.getSession();
String sql = "from Agent where userName='" + userName
+ "' and userPass='" + password + "'";
List list = this.getSession().createQuery(sql).list();
this.getSession().close();
return list;
}
/***************************************************************************
* 判断是否存在子ID
**************************************************************************/
public boolean getfuID(String agentId) {
boolean aa;
this.getSession();
String sql = "from Agent where parentId='" + agentId + "'";
List list = this.getSession().createQuery(sql).list();
if (list.size() > 0) {
aa = true;
} else {
aa = false;
}
this.getSession().close();
return aa;
}
/***************************************************************************
* 查询子Id
*
**************************************************************************/
public List getdata(String agentId) {
this.getSession();
String sql = "from Agent where parentId='" + agentId + "'";
List list = this.getSession().createQuery(sql).list();
this.getSession().close();
return list;
}
public void delete(Agent persistentInstance) {
log.debug("deleting Agent instance");
try {
getSession().delete(persistentInstance);
log.debug("delete successful");
} catch (RuntimeException re) {
log.error("delete failed", re);
throw re;
}
}
public Agent findById(java.lang.Integer id) {
log.debug("getting Agent instance with id: " + id);
try {
Agent instance = (Agent) getSession().get("com.bean.Agent", id);
return instance;
} catch (RuntimeException re) {
log.error("get failed", re);
throw re;
}
}
public List findByExample(Agent instance) {
log.debug("finding Agent instance by example");
try {
List results = getSession().createCriteria("com.bean.Agent").add(
Example.create(instance)).list();
log.debug("find by example successful, result size: "
+ results.size());
return results;
} catch (RuntimeException re) {
log.error("find by example failed", re);
throw re;
}
}
public List findByProperty(String propertyName, Object value) {
log.debug("finding Agent instance with property: " + propertyName
+ ", value: " + value);
try {
String queryString = "from Agent as model where model."
+ propertyName + "= ?";
Query queryObject = getSession().createQuery(queryString);
queryObject.setParameter(0, value);
return queryObject.list();
} catch (RuntimeException re) {
log.error("find by property name failed", re);
throw re;
}
}
public List findByAgentId(Object agentId) {
return findByProperty(AGENT_ID, agentId);
}
public List findByParentId(Object parentId) {
return findByProperty(PARENT_ID, parentId);
}
public List findByLevel(Object level) {
return findByProperty(LEVEL, level);
}
public List findByUserName(Object userName) {
return findByProperty(USER_NAME, userName);
}
public List findByUserPass(Object userPass) {
return findByProperty(USER_PASS, userPass);
}
public List findByStatus(Object status) {
return findByProperty(STATUS, status);
}
public List findByName(Object name) {
return findByProperty(NAME, name);
}
public List findAll() {
log.debug("finding all Agent instances");
try {
String queryString = "from Agent";
Query queryObject = getSession().createQuery(queryString);
return queryObject.list();
} catch (RuntimeException re) {
log.error("find all failed", re);
throw re;
}
}
public Agent merge(Agent detachedInstance) {
log.debug("merging Agent instance");
try {
Agent result = (Agent) getSession().merge(detachedInstance);
log.debug("merge successful");
return result;
} catch (RuntimeException re) {
log.error("merge failed", re);
throw re;
}
}
public void attachDirty(Agent instance) {
log.debug("attaching dirty Agent instance");
try {
getSession().saveOrUpdate(instance);
log.debug("attach successful");
} catch (RuntimeException re) {
log.error("attach failed", re);
throw re;
}
}
public void attachClean(Agent instance) {
log.debug("attaching clean Agent instance");
try {
getSession().lock(instance, LockMode.NONE);
log.debug("attach successful");
} catch (RuntimeException re) {
log.error("attach failed", re);
throw re;
}
}
}
ajax目录树
3星 · 超过75%的资源 需积分: 3 92 浏览量
2008-08-22
14:05:41
上传
评论
收藏 687KB RAR 举报
xwdengjie
- 粉丝: 4
- 资源: 11
最新资源
- 常用工具集参考用于图像等数据处理
- 音乐展示网页、基于Stenography的图像数字水印添加与提取,以及基于颜色矩和Tamura算法的图像相似度评估算法py源码
- 基于EmguCV(OpenCV .net封装),图像数字水印加解密算法的实现,其中包含最低有效位算法,离散傅里叶变换算法+文档书
- 基于matlab+DWT的图像水印项目,数字水印+源代码+文档说明+图片+报告pdf
- (优秀毕业设计)基于python实现的数字图像可视化水印系统的设计与实现,多种数字算法实现+源代码+文档说明+理论演示pdf
- 基于DWT-DCT-SVD和deflate压缩的数字水印方法python源码+Gui界面+演示视频(高分毕业设计)
- 基于matlab实现DWT、DCT、SVD算法数字图像水印可视化系统+GUI界面+文档说明+详细注释(高分毕业设计)
- NCIAE-Data-Structure大一大二笔记
- 学习wireshark笔记
- digital-image-数据可视化笔记
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈