📄 servicesdao.java
字号:
package com.tarena.oos.DAO;
// default package
import com.tarena.oos.model.Services;
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 Services.
* @see .Services
* @author MyEclipse Persistence Tools
*/
public class ServicesDAO extends BaseDAO {
private static final Log log = LogFactory.getLog(ServicesDAO.class);
//property constants
public static final String LAB_LOGIN_NAME = "labLoginName";
public static final String LAB_LOGIN_PASSWORD = "labLoginPassword";
public static final String LAB_IP = "labIp";
public static final String USER_STATUS = "userStatus";
public void save(Services transientInstance) {
log.debug("saving Services instance");
try {
getSession().saveOrUpdate(transientInstance);
getSession().beginTransaction().commit();
getSession().flush();
log.debug("save successful");
} catch (RuntimeException re) {
log.error("save failed", re);
throw re;
}
}
public void delete(Services persistentInstance) {
log.debug("deleting Services instance");
try {
getSession().delete(persistentInstance);
getSession().beginTransaction().commit();
getSession().flush();
log.debug("delete successful");
} catch (RuntimeException re) {
log.error("delete failed", re);
throw re;
}
}
public Services findById( java.lang.Integer id) {
log.debug("getting Services instance with id: " + id);
try {
Services instance = (Services) getSession()
.get(Services.class, id);
return instance;
} catch (RuntimeException re) {
log.error("get failed", re);
throw re;
}
}
public List findByExample(Services instance) {
log.debug("finding Services instance by example");
try {
List results = getSession()
.createCriteria("Services")
.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 Services instance with property: " + propertyName
+ ", value: " + value);
try {
String queryString = "from Services 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 findByLabLoginName(Object labLoginName) {
return findByProperty(LAB_LOGIN_NAME, labLoginName);
}
public List findByLabLoginPassword(Object labLoginPassword) {
return findByProperty(LAB_LOGIN_PASSWORD, labLoginPassword);
}
public List findByLabIp(Object labIp) {
return findByProperty(LAB_IP, labIp);
}
public List findByUserStatus(Object userStatus) {
return findByProperty(USER_STATUS, userStatus);
}
public List findAll() {
log.debug("finding all Services instances");
try {
String queryString = "from Services";
Query queryObject = getSession().createQuery(queryString);
return queryObject.list();
} catch (RuntimeException re) {
log.error("find all failed", re);
throw re;
}
}
public Services merge(Services detachedInstance) {
log.debug("merging Services instance");
try {
Services result = (Services) getSession()
.merge(detachedInstance);
log.debug("merge successful");
return result;
} catch (RuntimeException re) {
log.error("merge failed", re);
throw re;
}
}
public void attachDirty(Services instance) {
log.debug("attaching dirty Services instance");
try {
getSession().saveOrUpdate(instance);
getSession().beginTransaction().commit();
getSession().flush();
log.debug("attach successful");
} catch (RuntimeException re) {
log.error("attach failed", re);
throw re;
}
}
public void attachClean(Services instance) {
log.debug("attaching clean Services 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 + -