?? userinfodao.java
字號:
package com.zhou.dao;
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;
import com.zhou.po.Userinfo;
/**
* Data access object (DAO) for domain model class Userinfo.
*
* @see com.zhou.po.Userinfo
* @author MyEclipse Persistence Tools
*/
public class UserinfoDAO extends BaseHibernateDAO implements IUserinfoDAO {
private static final Log log = LogFactory.getLog(UserinfoDAO.class);
/* (non-Javadoc)
* @see com.zhou.dao.IUserinfoDAO#save(com.zhou.po.Userinfo)
*/
public void save(Userinfo transientInstance) {
log.debug("saving Userinfo instance");
try {
getSession().beginTransaction().begin();
getSession().save(transientInstance);
getSession().beginTransaction().commit();
log.debug("save successful");
} catch (RuntimeException re) {
log.error("save failed", re);
throw re;
}
}
/* (non-Javadoc)
* @see com.zhou.dao.IUserinfoDAO#delete(com.zhou.po.Userinfo)
*/
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;
}
}
/* (non-Javadoc)
* @see com.zhou.dao.IUserinfoDAO#findById(java.lang.Long)
*/
public Userinfo findById(java.lang.Long id) {
log.debug("getting Userinfo instance with id: " + id);
try {
Userinfo instance = (Userinfo) getSession().get(
"com.zhou.po.Userinfo", id);
return instance;
} catch (RuntimeException re) {
log.error("get failed", re);
throw re;
}
}
/* (non-Javadoc)
* @see com.zhou.dao.IUserinfoDAO#findByExample(com.zhou.po.Userinfo)
*/
public List findByExample(Userinfo instance) {
log.debug("finding Userinfo instance by example");
try {
List results = getSession().createCriteria("com.zhou.po.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;
}
}
/* (non-Javadoc)
* @see com.zhou.dao.IUserinfoDAO#findByProperty(java.lang.String, java.lang.Object)
*/
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 login(Object username,Object userpwd) {
try {
String queryString = "from Userinfo as model where model.username= ? and model.userpwd = ?";
Query queryObject = getSession().createQuery(queryString);
queryObject.setParameter(0, username);
queryObject.setParameter(1, userpwd);
return queryObject.list();
} catch (RuntimeException re) {
log.error("find by property name failed", re);
throw re;
}
}
public List findByAll() {
try {
String queryString = "from Userinfo as model";
Query queryObject = getSession().createQuery(queryString);
return queryObject.list();
} catch (RuntimeException re) {
log.error("find by property name failed", re);
throw re;
}
}
/* (non-Javadoc)
* @see com.zhou.dao.IUserinfoDAO#findByUsername(java.lang.Object)
*/
public List findByUsername(Object username) {
return findByProperty(USERNAME, username);
}
/* (non-Javadoc)
* @see com.zhou.dao.IUserinfoDAO#findByUserpwd(java.lang.Object)
*/
public List findByUserpwd(Object userpwd) {
return findByProperty(USERPWD, userpwd);
}
/* (non-Javadoc)
* @see com.zhou.dao.IUserinfoDAO#merge(com.zhou.po.Userinfo)
*/
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;
}
}
/* (non-Javadoc)
* @see com.zhou.dao.IUserinfoDAO#attachDirty(com.zhou.po.Userinfo)
*/
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;
}
}
/* (non-Javadoc)
* @see com.zhou.dao.IUserinfoDAO#attachClean(com.zhou.po.Userinfo)
*/
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;
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -