Home Random Page


CATEGORIES:

BiologyChemistryConstructionCultureEcologyEconomyElectronicsFinanceGeographyHistoryInformaticsLawMathematicsMechanicsMedicineOtherPedagogyPhilosophyPhysicsPolicyPsychologySociologySportTourism






EmployeeDaoImpl.java

 

package by.testrest.dao.impl;

 

import java.util.List;

 

import org.hibernate.SessionFactory;

import org.springframework.beans.factory.annotation.Autowired;

 

import by.testrest.dao.IEmployeeDao;

import by.testrest.domain.Employee;

 

 

public class EmployeeDaoImpl extends BaseAbstractDao

implements IEmployeeDao{

 

@Autowired

SessionFactory sessionFactory;

 

 

@SuppressWarnings("unchecked")

@Override

public Employee getEmployeeById(Long id) {

String queryString = "from Employee e where e.id = :id";

List<Employee> employers = sessionFactory.getCurrentSession().createQuery(queryString).setParameter("id", id).list();

if(employers.isEmpty()){

return null;

}else{

return employers.get(0);

}

}

 

@SuppressWarnings("unchecked")

@Override

public List<Employee> getAllEmployers() {

return(List<Employee>) super.findAll(sessionFactory, Employee.class, "name");

}

 

@SuppressWarnings("unchecked")

@Override

public List<Employee> getEmployersByDepartment(Long id) {

String queryString = "from Employee e where e.department.id = :id order by e.name asc";

List<Employee> employers = sessionFactory.getCurrentSession().createQuery(queryString).setParameter("id", id).list();

return employers;

}

 

@Override

public Long save(Employee employee) {

return super.saveEntity(sessionFactory, employee);

}

 

@Override

public void update(Employee employee) {

super.updateEntity(sessionFactory, employee);

}

 

@Override

public void deleteById(Long id) {

super.deleteEntityById(sessionFactory, Employee.class, id);

}

 

}

EmployeeDto.java

 

package by.testrest.dto;

 

import java.io.Serializable;

 

public class EmployeeDto implements Serializable{

 

/**

*

*/

private static final long serialVersionUID = -3563082593089385500L;

 

private Long id;

private Long department;

private String departmentName;

private String name;

private String fullName;

private String wage;

 

public EmployeeDto(){}

 

public Long getId() {

return id;

}

 

public void setId(Long id) {

this.id = id;

}

 

public Long getDepartment() {

return department;

}

 

public void setDepartment(Long department) {

this.department = department;

}

 

public String getName() {

return name;

}

 

public void setName(String name) {

this.name = name;

}

 

public String getFullName() {

return fullName;

}

 

public void setFullName(String fullName) {

this.fullName = fullName;

}

 

public String getWage() {

return wage;

}

 

public void setWage(String wage) {

this.wage = wage;

}

 

public String getDepartmentName() {

return departmentName;



}

 

public void setDepartmentName(String departmentName) {

this.departmentName = departmentName;

}

 

@Override

public String toString() {

return "EmployeeDto [id=" + id + ", name=" + name + "]";

}

 

@Override

public int hashCode() {

final int prime = 31;

int result = 1;

result = prime * result + ((id == null) ? 0 : id.hashCode());

result = prime * result + ((name == null) ? 0 : name.hashCode());

return result;

}

 

@Override

public boolean equals(Object obj) {

if (this == obj)

return true;

if (obj == null)

return false;

if (getClass() != obj.getClass())

return false;

EmployeeDto other = (EmployeeDto) obj;

if (id == null) {

if (other.id != null)

return false;

} else if (!id.equals(other.id))

return false;

if (name == null) {

if (other.name != null)

return false;

} else if (!name.equals(other.name))

return false;

return true;

}

}

DepartmentDto.java

 

package by.testrest.dto;

 

import java.io.Serializable;

 

public class DepartmentDto implements Serializable{

 

/**

*

*/

private static final long serialVersionUID = 5235110758965461224L;

 

private Long id;

private String name;

private String fullName;

private Double averageWage;

 

public DepartmentDto(){}

 

public Long getId() {

return id;

}

 

public void setId(Long id) {

this.id = id;

}

 

public String getName() {

return name;

}

 

public void setName(String name) {

this.name = name;

}

 

public Double getAverageWage() {

return averageWage;

}

 

public void setAverageWage(Double averageWage) {

this.averageWage = averageWage;

}

 

 

public String getFullName() {

return fullName;

}

 

public void setFullName(String fullName) {

this.fullName = fullName;

}

 

@Override

public String toString() {

return "DepartmentDto [id=" + id + ", name=" + name + "]";

}

 

@Override

public int hashCode() {

final int prime = 31;

int result = 1;

result = prime * result + ((id == null) ? 0 : id.hashCode());

result = prime * result + ((name == null) ? 0 : name.hashCode());

return result;

}

 

@Override

public boolean equals(Object obj) {

if (this == obj)

return true;

if (obj == null)

return false;

if (getClass() != obj.getClass())

return false;

DepartmentDto other = (DepartmentDto) obj;

if (id == null) {

if (other.id != null)

return false;

} else if (!id.equals(other.id))

return false;

if (name == null) {

if (other.name != null)

return false;

} else if (!name.equals(other.name))

return false;

return true;

}

 

}


Date: 2016-01-14; view: 717


<== previous page | next page ==>
Geographische Verteilung | EmployeeFormController.java
doclecture.net - lectures - 2014-2024 year. Copyright infringement or personal data (0.01 sec.)