customerdaoimpl.java
来自「非常经典的ssh整合实例」· Java 代码 · 共 29 行
JAVA
29 行
package com.briup.dao.impl;
import java.util.List;
import org.hibernate.Query;
import org.hibernate.Session;
import com.briup.bean.Customer;
import com.briup.common.HibernateSessionFactory;
import com.briup.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='"+name+"'");
List list=query.list();
if(list!=null&&list.size()>0)
return (Customer)list.get(0);
return null;
}
public void saveOrupdateCustomer(Customer customer) throws Exception {
Session session=HibernateSessionFactory.getSession();
session.saveOrUpdate(customer);
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?