package src;
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;
/**
* Data access object (DAO) for domain model class Userinfo.
*
* @see src.Userinfo
* @author MyEclipse Persistence Tools
*/
public class UserinfoDAO extends BaseHibernateDAO {
private static final Log log = LogFactory.getLog(UserinfoDAO.class);
// property constants
public static final String USER_NAME = "userName";
public static final String PASS_WORD = "passWord";
public void save(Userinfo transientInstance) {
log.debug("saving Userinfo instance");
try {
getSession().save(transientInstance);
log.debug("save successful");
} catch (RuntimeException re) {
log.error("save failed", re);
throw re;
}
}
public void delete(Userinfo persistentInstance) {
log.debug("deleting Userinfo instance");
try {
getSession().delete(persistentInstance);
log.debug("delete successful");
} catch (RuntimeException re) {
log.error("delete failed", re);
throw re;
}
}
public Userinfo findById(java.lang.Integer id) {
log.debug("getting Userinfo instance with id: " + id);
try {
Userinfo instance = (Userinfo) getSession().get("src.Userinfo", id);
return instance;
} catch (RuntimeException re) {
log.error("get failed", re);
throw re;
}
}
public List findByExample(Userinfo instance) {
log.debug("finding Userinfo instance by example");
try {
List results = getSession().createCriteria("src.Userinfo").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 Userinfo instance with property: " + propertyName
+ ", value: " + value);
try {
String queryString = "from Userinfo 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 findByUserName(Object userName) {
return findByProperty(USER_NAME, userName);
}
public List findByPassWord(Object passWord) {
return findByProperty(PASS_WORD, passWord);
}
public List findAll() {
log.debug("finding all Userinfo instances");
try {
String queryString = "from Userinfo";
Query queryObject = getSession().createQuery(queryString);
return queryObject.list();
} catch (RuntimeException re) {
log.error("find all failed", re);
throw re;
}
}
public Userinfo merge(Userinfo detachedInstance) {
log.debug("merging Userinfo instance");
try {
Userinfo result = (Userinfo) getSession().merge(detachedInstance);
log.debug("merge successful");
return result;
} catch (RuntimeException re) {
log.error("merge failed", re);
throw re;
}
}
public void attachDirty(Userinfo instance) {
log.debug("attaching dirty Userinfo instance");
try {
getSession().saveOrUpdate(instance);
log.debug("attach successful");
} catch (RuntimeException re) {
log.error("attach failed", re);
throw re;
}
}
public void attachClean(Userinfo instance) {
log.debug("attaching clean Userinfo instance");
try {
getSession().lock(instance, LockMode.NONE);
log.debug("attach successful");
} catch (RuntimeException re) {
log.error("attach failed", re);
throw re;
}
}
}
TestH(代Main方法的增删改查)
5星 · 超过95%的资源 需积分: 10 22 浏览量
2007-11-22
18:11:51
上传
评论
收藏 474KB RAR 举报
shuai_1314
- 粉丝: 17
- 资源: 10
最新资源
- Screenshot_20240427_031602.jpg
- 网页PDF_2024年04月26日 23-46-14_QQ浏览器网页保存_QQ浏览器转格式(6).docx
- 直接插入排序,冒泡排序,直接选择排序.zip
- 在排序2的基础上,再次对快排进行优化,其次增加快排非递归,归并排序,归并排序非递归版.zip
- 实现了7种排序算法.三种复杂度排序.三种nlogn复杂度排序(堆排序,归并排序,快速排序)一种线性复杂度的排序.zip
- 冒泡排序 直接选择排序 直接插入排序 随机快速排序 归并排序 堆排序.zip
- 课设-内部排序算法比较 包括冒泡排序、直接插入排序、简单选择排序、快速排序、希尔排序、归并排序和堆排序.zip
- Python排序算法.zip
- C语言实现直接插入排序、希尔排序、选择排序、冒泡排序、堆排序、快速排序、归并排序、计数排序,并带图详解.zip
- 常用工具集参考用于图像等数据处理
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈