📄 paywaydaoimpl.java
字号:
package cn.com.tarena.ecport.dao.impl;
import java.util.List;
import org.hibernate.LockMode;
import org.hibernate.Query;
import org.hibernate.criterion.Example;
import cn.com.tarena.ecport.common.util.HibernateUtil;
import cn.com.tarena.ecport.dao.IPayWayDAO;
import cn.com.tarena.ecport.exception.ECPortException;
import cn.com.tarena.ecport.pojo.PayWay;
public class PayWayDAOImpl implements IPayWayDAO {
@SuppressWarnings("unchecked")
public List<PayWay> findAllPayWay() throws ECPortException {
try {
List<PayWay> payWay = HibernateUtil.getSessionFactory().getCurrentSession().createQuery("from PayWay").list();
return payWay;
} catch (RuntimeException re) {
throw re;
}
}
public void delete(PayWay persistencePojo) {
try {
HibernateUtil.getSessionFactory().getCurrentSession().delete(persistencePojo);
} catch (RuntimeException e) {
throw e;
}
}
@SuppressWarnings("unchecked")
public List<PayWay> findByExample(PayWay ExamplePojo) {
try {
List<PayWay> results = HibernateUtil.getSessionFactory().getCurrentSession().createCriteria("PayWay").add(
Example.create(ExamplePojo)).list();
return results;
} catch (RuntimeException re) {
throw re;
}
}
public PayWay findById(Long id) {
try {
PayWay payWays = (PayWay) HibernateUtil.getSessionFactory().getCurrentSession().get(PayWay.class, id);
return payWays;
} catch (RuntimeException e) {
throw e;
}
}
@SuppressWarnings("unchecked")
public List<PayWay> findByProperty(String propertyName, Object value) {
try {
String queryString = "from PayWay as model where model."+ propertyName + "= ?";
Query queryObject = HibernateUtil.getSessionFactory().getCurrentSession().createQuery(queryString);
queryObject.setParameter(0, value);
return queryObject.list();
} catch (RuntimeException re) {
throw re;
}
}
public void lock(PayWay pojo) {
try {
HibernateUtil.getSessionFactory().getCurrentSession().lock(pojo, LockMode.READ);
} catch (RuntimeException e) {
throw e;
}
}
public PayWay merge(PayWay detachedPojo) {
try {
PayWay result = (PayWay) HibernateUtil.getSessionFactory().getCurrentSession().merge(detachedPojo);
return result;
} catch (RuntimeException re) {
throw re;
}
}
public void save(PayWay transientPojo) {
try {
HibernateUtil.getSessionFactory().getCurrentSession().save(transientPojo);
} catch (RuntimeException e) {
throw e;
}
}
public void saveOrUpdate(PayWay pojo) {
try {
HibernateUtil.getSessionFactory().getCurrentSession().saveOrUpdate(pojo);
} catch (RuntimeException re) {
throw re;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -