📄 employeedao.java
字号:
/**
*
*/
package com.qrsx.qrsxcrm.dao;
import java.util.ArrayList;
import java.util.List;
import org.hibernate.Query;
import com.qrsx.qrsxcrm.model.Duty;
import com.qrsx.qrsxcrm.model.Employee;
/**
* @author Administrator
*
*/
public class EmployeeDAO extends BaseDAO
{
@SuppressWarnings("unchecked")
public EmployeeDAO(Class Employee) {
super(Employee);
// TODO Auto-generated constructor stub
}
public void updates(Employee employee)
{
Employee employee1 = new Employee();
employee1=(Employee) session.get(Employee.class, employee.getId());
employee1.setAddress(employee.getAddress());
employee1.setBirthday(employee.getBirthday());
employee1.setCardId(employee.getCardId());
employee1.setEmployeeId(employee.getEmployeeId());
employee1.setEmployeeName(employee.getEmployeeName());
employee1.setHome(employee.getHome());
employee1.setMobilephone(employee.getMobilephone());
employee1.setSex(employee.getSex());
employee1.setTelephone(employee.getTelephone());
employee1.setDept(employee.getDept());
employee1.setDuty(employee.getDuty());
session.update(employee1);
}
@SuppressWarnings("unchecked")
public List<Employee> lists(Employee employee){
List<Employee> list=new ArrayList<Employee>();
String sql="from Employee t where 1=1 ";
if(employee.getEmployeeName()!=null&&employee.getEmployeeName().trim()!=""){
sql+=" and t.employeeName like '%"+employee.getEmployeeName().trim()+"%' ";
}
if(employee.getEmployeeId()!=null&&employee.getEmployeeId().trim()!=""){
sql+=" and t.employeeId like '%"+employee.getEmployeeId().trim()+"%' ";
}
if(employee.getSex()!=null){
sql+=" and t.sex like '%"+employee.getSex()+"%' ";
}
if(employee.getBirthday()!=null){
sql+=" and t.birthday like '%"+employee.getBirthday()+"%' ";
}
if(employee.getMobilephone()!=null&&employee.getMobilephone().trim()!=""){
sql+=" and t.mobilephone like '%"+employee.getMobilephone().trim()+"%' ";
}
if(employee.getTelephone()!=null&&employee.getTelephone().trim()!=""){
sql+=" and t.telephone like '%"+employee.getTelephone().trim()+"%' ";
}
if(employee.getDept()!=null){
sql+=" and t.dept.id like '%"+employee.getDept().getId().trim()+"%' ";
}
if(employee.getDuty()!=null){
sql+=" and t.duty.id like '%"+employee.getDuty().getId().trim()+"%' ";
}
Query query=session.createQuery(sql);
list=query.list();
return list;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -