📄 ordertabledao.java
字号:
package com.xfaccp.bookonline.hib.dao;
import java.util.List;
import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.LockMode;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.criterion.Example;
import com.xfaccp.bookonline.hib.dao.base.BaseHibernateDAO;
import com.xfaccp.bookonline.hib.dto.OrderTable;
/**
* Data access object (DAO) for domain model class OrderTable.
*
* @see com.xfaccp.bookonline.hib.dto.OrderTable
* @author MyEclipse - Hibernate Tools
*/
public class OrderTableDAO extends BaseHibernateDAO {
/**
*
*/
private static final long serialVersionUID = 1L;
private static final Log log = LogFactory.getLog(OrderTableDAO.class);
// property constants
public static final String ORDERDATE = "orderdate";
public OrderTable findById(java.lang.Integer id) {
log.debug("getting OrderTable instance with id: " + id);
Session session = this.getSession();
try {
OrderTable instance = (OrderTable) session.get(
"com.xfaccp.bookonline.hib.dto.OrderTable", id);
return instance;
} catch (RuntimeException re) {
log.error("get failed", re);
throw re;
} finally {
session.close();
}
}
public List findByExample(OrderTable instance) {
log.debug("finding OrderTable instance by example");
Session session = this.getSession();
try {
List results = session.createCriteria(
"com.xfaccp.bookonline.hib.dto.OrderTable").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;
} finally {
session.close();
}
}
public List findByProperty(String propertyName, Object value) {
log.debug("finding OrderTable instance with property: " + propertyName
+ ", value: " + value);
Session session = this.getSession();
try {
String queryString = "from OrderTable as model where model."
+ propertyName + "= ?";
Query queryObject = session.createQuery(queryString);
queryObject.setParameter(0, value);
return queryObject.list();
} catch (RuntimeException re) {
log.error("find by property name failed", re);
throw re;
} finally {
session.close();
}
}
public List findByOrderdate(Object orderdate) {
return findByProperty(ORDERDATE, orderdate);
}
public OrderTable merge(OrderTable detachedInstance) {
log.debug("merging OrderTable instance");
Session session = this.getSession();
try {
OrderTable result = (OrderTable) session.merge(detachedInstance);
log.debug("merge successful");
return result;
} catch (RuntimeException re) {
log.error("merge failed", re);
throw re;
} finally {
session.close();
}
}
public void attachDirty(OrderTable instance) {
log.debug("attaching dirty OrderTable instance");
Session session = this.getSession();
try {
session.saveOrUpdate(instance);
log.debug("attach successful");
} catch (RuntimeException re) {
log.error("attach failed", re);
throw re;
} finally {
session.close();
}
}
public void attachClean(OrderTable instance) {
log.debug("attaching clean OrderTable instance");
Session session = this.getSession();
try {
session.lock(instance, LockMode.NONE);
log.debug("attach successful");
} catch (RuntimeException re) {
log.error("attach failed", re);
throw re;
} finally {
session.close();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -