src/com/jiudai/dao/CustomerDAO.java
(开头部分) 2KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
package com.jiudai.dao;
import java.util.List;
import org.hibernate.HibernateException;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.Transaction;
import com.jiudai.Utils.HibernateUtil;
import com.jiudai.domain.Customer;
public class CustomerDAO {
/*查询所有客户信息*/
public List QueryAllCustomer() {
Session s = null;
try {
s = HibernateUtil.getSession();
String hql = "From Customer";
Query q = s.createQuery(hql);
List customerList = q.list();
return customerList;
} finally {
HibernateUtil.closeSession();
}
}
/*根据客户名称查询客户信息*/
public Customer GetCustomer(String customername) {
System.out.print(customername);
Session s = null;
try {
s = HibernateUtil.getSession();
Customer customer = (Customer)s.get(Customer.class, customername);
return customer;
} finally {
HibernateUtil.closeSession();
}
}
public void ModifyCustomer(Customer customer) {
Session s = null;
Transaction tx = null;
try {
s = HibernateUtil.getSession();
tx = s.beginTransaction();
s.update(customer);
tx.commit();
} catch (HibernateException e) {
if(tx != null)
tx.rollback();
throw e;
} finally {
HibernateUtil.closeSession();
}
}
后面还有 37 行代码,购买后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。
