?? sortdao.java
字號:
package dream.ourshopping.persistence;
import java.util.List;
import org.apache.log4j.Logger;
import org.hibernate.LockMode;
import org.hibernate.Query;
import org.hibernate.Transaction;
import org.hibernate.criterion.Example;
import dream.ourshopping.domain.Sort;
/**
* Data access object (DAO) for domain model class Sort.
*
* @see com.study.hibernate.Sort
* @author MyEclipse - Hibernate Tools
*/
public class SortDAO extends BaseHibernateDAO {
private static Logger log = Logger.getLogger(SortDAO.class.getName());
// property constants
public static final String NAME = "name";
public void save(Sort transientInstance) {
log.debug("saving Sort instance");
try {
Transaction ts = getSession().beginTransaction();
getSession().save(transientInstance);
ts.commit();
log.debug("save successful");
} catch (RuntimeException re) {
log.error("save failed", re);
throw re;
}
}
public List findMaxId() {
log.debug("getting Sort instance All: ");
try {
Query q = getSession().createQuery("select max(id) from Sort ");
List instance = q.list();
return instance;
} catch (RuntimeException re) {
log.error("get failed", re);
throw re;
}
}
public void delete(Sort persistentInstance) {
log.debug("deleting Sort instance");
try {
Transaction ts = getSession().beginTransaction();
getSession().delete(persistentInstance);
ts.commit();
log.debug("delete successful");
} catch (RuntimeException re) {
log.error("delete failed", re);
throw re;
}
}
public List findById(java.lang.Integer id) {
log.debug("getting Sort instance with id: " + id);
try {
List instance = getSession().createQuery("from Sort s where s.id=" +id).list();
return instance;
} catch (RuntimeException re) {
log.error("get failed", re);
throw re;
}
}
public List findAll() {
log.debug("getting Sort instance All: ");
try {
List instance = getSession().createQuery("from Sort").list();
return instance;
} catch (RuntimeException re) {
log.error("get failed", re);
throw re;
}
}
public List findAllByList(int b, int s) {
log.debug("getting Sort instance All: ");
try {
Query q = getSession().createQuery("from Sort");
q.setFirstResult(b);
q.setMaxResults(s);
List instance = q.list();
return instance;
} catch (RuntimeException re) {
log.error("get failed", re);
throw re;
}
}
public List findcount() {
log.debug("getting Sort instance All: ");
try {
Query q = getSession().createQuery("select count(*) from Sort");
List instance = q.list();
return instance;
} catch (RuntimeException re) {
log.error("get failed", re);
throw re;
}
}
public List findByExample(Sort instance) {
log.debug("finding Sort instance by example");
try {
List results = getSession().createCriteria(
"dream.ourshopping.domain.Sort").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 Sort instance with property: " + propertyName
+ ", value: " + value);
try {
String queryString = "from Sort 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 findByName(Object name) {
return findByProperty(NAME, name);
}
public Sort merge(Sort detachedInstance) {
log.debug("merging Sort instance");
try {
Sort result = (Sort) getSession().merge(detachedInstance);
log.debug("merge successful");
return result;
} catch (RuntimeException re) {
log.error("merge failed", re);
throw re;
}
}
public void attachDirty(Sort instance) {
log.debug("attaching dirty Sort instance");
try {
Transaction ts = getSession().beginTransaction();
getSession().saveOrUpdate(instance);
ts.commit();
log.debug("attach successful");
} catch (RuntimeException re) {
log.error("attach failed", re);
throw re;
}
}
public void attachClean(Sort instance) {
log.debug("attaching clean Sort instance");
try {
getSession().lock(instance, LockMode.NONE);
log.debug("attach successful");
} catch (RuntimeException re) {
log.error("attach failed", re);
throw re;
}
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -