📄 studentserviceimp.java
字号:
/**
*文件功能:InnoDB free: 0 kB
*/
package com.tech.service.imp;
import java.util.List;
import com.common.dao.DaoSupport;
import com.common.exception.BusinessException;
import com.common.util.BeanUtils;
import com.tech.model.Student;
import com.tech.service.StudentService;
/**
*InnoDB free: 0 kB
* @作者 徐建协
* @日期 2009-02-05
*/
public class StudentServiceImp implements StudentService {
private DaoSupport<Student,Long> studentDao;
public void setStudentDao(DaoSupport<Student,Long> studentDao) {
this.studentDao = studentDao;
}
/* (non-Javadoc)
* @see com.common.service.BaseService#getEntity(java.io.Serializable)
*/
public Student getEntity(Long id) throws BusinessException {
try {
return studentDao.getEntity(id);
} catch (Exception e) {
e.printStackTrace();
throw new BusinessException("StudentServiceImp 不能获取主键为:" + id
+ "的数据" + e.toString());
}
}
/* (non-Javadoc)
* @see com.common.service.BaseService#loadEntity(java.io.Serializable)
*/
public Student loadEntity(Long id) throws BusinessException {
try {
return studentDao.loadEntity(id);
} catch (Exception e) {
e.printStackTrace();
throw new BusinessException("StudentServiceImp 不能获取主键为:" + id
+ "的数据" + e.toString());
}
}
/* (non-Javadoc)
* @see com.common.service.BaseService#removeEntity(java.lang.Object)
*/
public void removeEntity(Student entity) throws BusinessException {
try {
studentDao.removeEntity(entity);
} catch (Exception e) {
e.printStackTrace();
throw new BusinessException("删除异常:"
+ e.getMessage());
}
}
/* (non-Javadoc)
* @see com.common.service.BaseService#removeEntity(T[])
*/
public void removeEntity(Student[] array) throws BusinessException {
try {
studentDao.removeEntity(array);
} catch (Exception e) {
e.printStackTrace();
throw new BusinessException("删除异常:"
+ e.getMessage());
}
}
/* (non-Javadoc)
* @see com.common.service.BaseService#saveEntity(java.lang.Object)
*/
public void saveEntity(Student entity) throws BusinessException {
try {
studentDao.saveEntity(entity);
} catch (Exception e) {
e.printStackTrace();
throw new BusinessException("添加异常:"
+ e.getMessage());
}
}
/* (non-Javadoc)
* @see com.common.service.BaseService#saveEntity(T[])
*/
public void saveEntity(Student[] array) throws BusinessException {
try {
studentDao.saveEntity(array);
} catch (Exception e) {
e.printStackTrace();
throw new BusinessException("添加异常:"
+ e.getMessage());
}
}
/* (non-Javadoc)
* @see com.common.service.BaseService#updateEntity(java.lang.Object)
*/
public void updateEntity(Student entity) throws BusinessException {
try {
Student entityLoad = studentDao.getEntity(entity.getId());
// 拷贝不需要更新的字段内容
//PropertyUtils.copyProperties(entityLoad,entity);
BeanUtils.copyProperties(entityLoad,entity);
studentDao.updateEntity(entityLoad);
} catch (Exception e) {
e.printStackTrace();
throw new BusinessException("更新异常:"
+ e.getMessage());
}
}
/* (non-Javadoc)
* @see com.common.service.BaseService#updateEntity(T[])
*/
public void updateEntity(Student[] array) throws BusinessException {
try {
studentDao.updateEntity(array);
} catch (Exception e) {
e.printStackTrace();
throw new BusinessException("更新异常:"
+ e.getMessage());
}
}
public boolean isExists(Student t,List<String> names) throws BusinessException{
try {
return studentDao.isExists(t,names);
} catch (Exception e) {
e.printStackTrace();
throw new BusinessException("查找异常:"
+ e.getMessage());
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -