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

📄 customerdaoimpl.java

📁 该系统的主要功能是
💻 JAVA
字号:
package com.laoniu.dao.impl;

import java.util.List;

import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.Transaction;

import com.laoniu.bean.Customer;


import com.laoniu.common.HibernateSessionFactory;

import com.laoniu.dao.ICustomerDao;


public class CustomerDaoImpl implements ICustomerDao {
	
	public Customer findCustomerByName(String name) throws Exception {
		Session session=HibernateSessionFactory.getSession();
		Query query=session.createQuery("from Customer where name=?");
		query.setString(0, name);
		List list = query.list();
		if(list.size()>0)
			return (Customer)list.get(0);
		return null;
	}

	public void saveOrupdateCustomer(Customer customer) throws Exception {
		Session session=HibernateSessionFactory.getSession();
		session.saveOrUpdate(customer);  
	}
	public Customer findCustomerById(Long id) throws Exception 
	{
		Session session=HibernateSessionFactory.getSession();
		String hql="from Customer where id=?";
		Query query=session.createQuery(hql);
		query.setLong(0,id);
		return (Customer)query.list().get(0);
	}
}

⌨️ 快捷键说明

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