📄 orderitemtabledao.java
字号:
package com.xfaccp.bookonline.hib.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.Session;
import org.hibernate.criterion.Example;
import com.xfaccp.bookonline.hib.dao.base.BaseHibernateDAO;
import com.xfaccp.bookonline.hib.dto.OrderitemTable;
/**
* Data access object (DAO) for domain model class OrderitemTable.
*
* @see com.xfaccp.bookonline.hib.dto.OrderitemTable
* @author MyEclipse - Hibernate Tools
*/
public class OrderitemTableDAO extends BaseHibernateDAO {
/**
*
*/
private static final long serialVersionUID = 1L;
private static final Log log = LogFactory.getLog(OrderitemTableDAO.class);
// property constants
public static final String QUANTITY = "quantity";
public OrderitemTable findById(java.lang.Integer id) {
log.debug("getting OrderitemTable instance with id: " + id);
Session session = this.getSession();
try {
OrderitemTable instance = (OrderitemTable) session.get(
"com.xfaccp.bookonline.hib.dto.OrderitemTable", id);
return instance;
} catch (RuntimeException re) {
log.error("get failed", re);
throw re;
} finally {
session.close();
}
}
public List findByExample(OrderitemTable instance) {
log.debug("finding OrderitemTable instance by example");
Session session = this.getSession();
try {
List results = session.createCriteria(
"com.xfaccp.bookonline.hib.dto.OrderitemTable").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 OrderitemTable instance with property: "
+ propertyName + ", value: " + value);
Session session = this.getSession();
try {
String queryString = "from OrderitemTable 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 findByQuantity(Object quantity) {
return findByProperty(QUANTITY, quantity);
}
public OrderitemTable merge(OrderitemTable detachedInstance) {
log.debug("merging OrderitemTable instance");
Session session = this.getSession();
try {
OrderitemTable result = (OrderitemTable) 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(OrderitemTable instance) {
log.debug("attaching dirty OrderitemTable 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(OrderitemTable instance) {
log.debug("attaching clean OrderitemTable 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 + -