⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 orderlinedaoimpl.java

📁 本系统是网上购物的详细代码
💻 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.IOrderLineDAO;
import cn.com.tarena.ecport.exception.ECPortException;
import cn.com.tarena.ecport.pojo.OrderLine;

public class OrderLineDAOImpl implements IOrderLineDAO {

	@SuppressWarnings("unchecked")
	public List<OrderLine> findAllOrderLine() throws ECPortException {
		try {
			List<OrderLine> orderLines = HibernateUtil.getSessionFactory().getCurrentSession().createQuery("from OrderLine").list();
			return orderLines;
		} catch (RuntimeException re) {
			throw re;
		}
	}

	public void delete(OrderLine persistencePojo) {
		try {
			HibernateUtil.getSessionFactory().getCurrentSession().delete(persistencePojo);
		} catch (RuntimeException re) {
			throw re;
		}
	}

	@SuppressWarnings("unchecked")
	public List<OrderLine> findByExample(OrderLine ExamplePojo) {
		try {
			List<OrderLine> results = HibernateUtil.getSessionFactory().getCurrentSession().createCriteria("OrderLine").add(
                                      Example.create(ExamplePojo)).list();
			return results;
		} catch (RuntimeException re) {
			throw re;
		}
	}

	public OrderLine findById(Long id) {
		try {
			OrderLine instance = (OrderLine) HibernateUtil.getSessionFactory().getCurrentSession().get(OrderLine.class, id);
			return instance;
		} catch (RuntimeException re) {
			throw re;
		}
	}

	@SuppressWarnings("unchecked")
	public List<OrderLine> findByProperty(String propertyName, Object value) {
		String hql = "from OrderLine as o where o."+propertyName+"=?";
		try {
			Query q = HibernateUtil.getSessionFactory().getCurrentSession().createQuery(hql);
			q.setParameter(0, value);
			return q.list();
		} catch (RuntimeException e) {
		    throw e;
		}
	}

	public void lock(OrderLine pojo) {
		try {
			HibernateUtil.getSessionFactory().getCurrentSession().lock(pojo, LockMode.READ);
		} catch (RuntimeException e) {
			throw e;
		}
	}

	public OrderLine merge(OrderLine detachedPojo) {
		try {
			OrderLine result = (OrderLine) HibernateUtil.getSessionFactory().getCurrentSession().merge(detachedPojo);
			return result;
		} catch (RuntimeException re) {
			throw re;
		}
	}

	public void save(OrderLine transientPojo) {
		try {
			HibernateUtil.getSessionFactory().getCurrentSession().save(transientPojo);
		} catch (RuntimeException e) {
			throw e;
		}
	}

	public void saveOrUpdate(OrderLine pojo) {
		try {
			HibernateUtil.getSessionFactory().getCurrentSession().saveOrUpdate(pojo);
		} catch (RuntimeException e) {
			throw e;
		}
	}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -