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

📄 employmenttest.java

📁 一个自娱自乐的demo 开发环境 apache-tomcat-6.0.16 Mysql 5.1.11 Jdk 1.6 文件结构如下 --MyGame -----MyGam
💻 JAVA
字号:
/**
 *	2007/11/05
 *	@version
 *	@author 何 貝
 */
package com.hb.base.test.dao.organization;

import com.hb.base.dao.common.PersonDao;
import com.hb.base.dao.organization.DepartmentDao;
import com.hb.base.dao.organization.EmployeeDao;
import com.hb.base.dao.organization.EmploymentDao;
import com.hb.base.dao.organization.JobDao;
import com.hb.base.dao.organization.JobInfoDao;
import com.hb.base.dao.organization.SalaryDao;
import com.hb.base.domain.organization.Employee;
import com.hb.base.domain.organization.Employment;
import com.hb.base.domain.organization.Job;
import com.hb.base.domain.organization.JobInfo;
import com.hb.base.domain.organization.Salary;
import com.hb.core.test.dao.HibernateDaoTestCase;

public class EmploymentTest extends HibernateDaoTestCase {
	private JobInfoDao jobInfoDao;
	private JobDao jobDao;
	private DepartmentDao departmentDao;
	private EmploymentDao employmentDao;
	private EmployeeDao employeeDao;
	private PersonDao personDao;
	private SalaryDao salaryDao;

	public void testInsertEmployment() {

		for (int i = 0; i < 54; i++) {
			// ------------------------------------------
			Employee employee = new Employee();

			String employeeID = getMaxID(i);
			employee.setEmployeeID(employeeID);
			employee.setPassword(employeeID);

			employeeDao.save(employee);
			// ------------------------------------------
			Salary salary = new Salary();

			salary.setSalaryID(getMaxID(i));
			salary.setAmount(10000);

			salaryDao.save(salary);
			// ------------------------------------------
			Employment employment = new Employment();

			employment.setStartDate(getCurrentDate());
			employment.setEndDate(getMaxDate());
			employment.setPerson(personDao.get(i + 1));
			employment.setEmployee(employee);
			employment.setSalary(salary);

			employmentDao.save(employment);
			// ------------------------------------------
			Job job = new Job();
			JobInfo jobInfo = null;
			if (i + 1 > 28) {
				jobInfo = jobInfoDao.get(i + 1 - 28);
			} else {
				jobInfo = jobInfoDao.get(i + 1);
			}

			job.setJobID(jobInfo.getJobInfoID());
			job.setDepartment(departmentDao.getDepartmentById(jobInfo.getDepartment().getDepartmentID()));
			job.setEmployee(employee);
			job.setStartDate(getCurrentDate());
			job.setEndDate(getMaxDate());

			employee.addJob(job);

			employeeDao.save(employee);

		}
	}

	public void testInsertEmployment1() {
		Employee employee = employeeDao.get(1);

		Job job = new Job();
		job.setJobID(jobInfoDao.get(2).getJobInfoID());
		job.setDepartment(departmentDao.get(1));
		job.setEmployee(employee);
		job.setStartDate(getCurrentDate());
		job.setEndDate(getMaxDate());

		employee.addJob(job);

		employeeDao.save(employee);
	}

	public EmploymentDao getEmploymentDao() {
		return employmentDao;
	}

	public void setEmploymentDao(EmploymentDao employmentDao) {
		this.employmentDao = employmentDao;
	}

	public EmployeeDao getEmployeeDao() {
		return employeeDao;
	}

	public void setEmployeeDao(EmployeeDao employeeDao) {
		this.employeeDao = employeeDao;
	}

	public PersonDao getPersonDao() {
		return personDao;
	}

	public void setPersonDao(PersonDao personDao) {
		this.personDao = personDao;
	}

	public SalaryDao getSalaryDao() {
		return salaryDao;
	}

	public void setSalaryDao(SalaryDao salaryDao) {
		this.salaryDao = salaryDao;
	}

	public DepartmentDao getDepartmentDao() {
		return departmentDao;
	}

	public void setDepartmentDao(DepartmentDao departmentDao) {
		this.departmentDao = departmentDao;
	}

	public JobInfoDao getJobInfoDao() {
		return jobInfoDao;
	}

	public void setJobInfoDao(JobInfoDao jobInfoDao) {
		this.jobInfoDao = jobInfoDao;
	}

	public JobDao getJobDao() {
		return jobDao;
	}

	public void setJobDao(JobDao jobDao) {
		this.jobDao = jobDao;
	}
}

⌨️ 快捷键说明

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