📄 tpzlserviceimp.java
字号:
/**
*文件功能:InnoDB free: 0 kB
*/
package com.tech.service.imp;
import java.util.List;
import org.hibernate.criterion.DetachedCriteria;
import org.springframework.dao.DataAccessException;
import com.common.dao.DaoSupport;
import com.common.dao.HibernateDaoHelper;
import com.common.exception.BusinessException;
import com.common.util.BeanUtils;
import com.common.util.PaginationSupport;
import com.tech.model.Tpzl;
import com.tech.dao.TpzlDao;
import com.tech.service.TpzlService;
import com.tech.model.query.Primary;
/**
*InnoDB free: 0 kB
* @作者 徐建协
* @日期 2009-03-20
*/
public class TpzlServiceImp implements TpzlService {
private HibernateDaoHelper hibernateDaoHelper;
private TpzlDao tpzlDao;
public TpzlDao getTpzlDao() {
return tpzlDao;
}
public void setTpzlDao(TpzlDao tpzlDao) {
this.tpzlDao = tpzlDao;
}
/***************************************************************************
* 获取实体对象的所有数据
*
* @return
*/
@SuppressWarnings("unchecked")
public List<Tpzl> findAllEntity() throws BusinessException {
try {
return tpzlDao.findAllEntity();
} catch (Exception e) {
e.printStackTrace();
throw new BusinessException("TpzlServiceImpl " + e.toString());
}
}
/***************************************************************************
* 根据主键获取单个实体对象
*
* @param id
* @return
*/
@SuppressWarnings("unchecked")
public Tpzl loadEntity(Long id) throws BusinessException {
try {
return tpzlDao.loadEntity(id);
} catch (Exception e) {
e.printStackTrace();
throw new BusinessException("TpzlServiceImpl 不能获取主键为:" + id
+ "的数据" + e.toString());
}
}
/***************************************************************************
* 根据主键获取单个实体对象,如果返回null
*
* @param id
* @return
*/
@SuppressWarnings("unchecked")
public Tpzl getEntity(Long id) throws BusinessException {
try {
return tpzlDao.getEntity(id);
} catch (Exception e) {
e.printStackTrace();
throw new BusinessException("TpzlServiceImpl 不能获取主键为:" + id
+ "的数据" + e.toString());
}
}
/***************************************************************************
* 根据主键获取单个实体对象,如果没有抛出异常
*
* @param id
* @return
*/
public void saveEntity(Tpzl entity) throws BusinessException {
try {
tpzlDao.saveEntity(entity);
} catch (Exception e) {
e.printStackTrace();
throw new BusinessException("添加异常:"
+ e.getMessage());
}
}
public void saveEntity(Tpzl[] array) throws BusinessException{
try {
tpzlDao.saveEntity(array);
} catch (Exception e) {
e.printStackTrace();
throw new BusinessException("添加异常:"
+ e.getMessage());
}
}
/***************************************************************************
* 更新单个实体对象
*
* @param entity
* @throws DataAccessException
*/
public void updateEntity(Tpzl entity) throws BusinessException {
try {
Tpzl entityLoad = getEntity(entity.getId());
// 拷贝不需要更新的字段内容
//PropertyUtils.copyProperties(entityLoad,entity);
BeanUtils.copyProperties(entityLoad,entity);
tpzlDao.updateEntity(entityLoad);
} catch (Exception e) {
e.printStackTrace();
throw new BusinessException("更新异常:"
+ e.getMessage());
}
}
/***************************************************************************
* 保存或者更新实体对象
*
* @param entity
*/
public void saveOrUpdateEntity(Tpzl entity) {
try {
tpzlDao.updateEntity(entity);
} catch (Exception e) {
e.printStackTrace();
throw new BusinessException("保存异常:"
+ e.getMessage());
}
}
/***************************************************************************
* 删除实体对象数据
*
* @param entity
*/
public void removeEntity(Tpzl entity) {
try {
tpzlDao.removeEntity(entity);
} catch (Exception e) {
e.printStackTrace();
throw new BusinessException("删除异常:"
+ e.getMessage());
}
}
/***************************************************************************
* 删除实体对象数据
*
* @param entity
*/
public void removeEntity(Long id) {
try {
tpzlDao.removeEntity(id);
} catch (Exception e) {
e.printStackTrace();
throw new BusinessException("删除异常:"
+ e.getMessage());
}
}
public void removeHyxx(Tpzl tpzl) throws BusinessException{
try {
String hql="delete from Tpzl where id=? and tid=?";
tpzlDao.batchUpdateOrDelete(hql,new Object[]{tpzl.getId(),tpzl.getTid()});
} catch (Exception e) {
e.printStackTrace();
throw new BusinessException("删除异常:"
+ e.getMessage());
}
}
/***************************************************************************
* 批量删除实体对象数据
*
* @param entity
*/
public void removeEntity(Long[] idList) {
try {
tpzlDao.removeEntity(idList);
} catch (Exception e) {
e.printStackTrace();
throw new BusinessException("批量删除异常:"
+ e.getMessage());
}
}
public PaginationSupport find(PaginationSupport ps,
DetachedCriteria detachedCriteria) throws BusinessException {
try {
return tpzlDao.findPageByCriteria(detachedCriteria, ps);
} catch (Exception e) {
e.printStackTrace();
throw new BusinessException("TpzlServiceImpl 查询异常:"
+ e.toString());
}
}
/***************************************************************************
* 根据传入的sql语句获取查询值,一般用户记录数
*
* @param sql
* @param alias
*/
public int countBySQL(final String sql,final String alias){
try {
return tpzlDao.countBySQL(sql, alias);
} catch (Exception e) {
e.printStackTrace();
throw new BusinessException("TpzlImpl 查询异常:"
+ e.toString());
}
}
public List<Primary> getTpzlList(Long tid,Long tplybz){
String sql="select t.id {t.id} from tpzl t where t.tid=? and t.tplybz=?";
return hibernateDaoHelper.findBySQL(sql, "t", Primary.class,new Object[]{tid,tplybz}, false, -1, -1);
}
public List<Primary> getTpzlList(Long tid,Long tplybz,Long tplxbz){
String sql="select t.id {t.id} from tpzl t where t.tid=? and t.tplybz=? and t.tplxbz=?";
return hibernateDaoHelper.findBySQL(sql, "t", Primary.class,new Object[]{tid,tplybz,tplxbz}, false, -1, -1);
}
public List<Primary> getTpzlList(Long tid,Long tplybz,Long tplxbz,Long fr){
String sql="select t.id {t.id} from tpzl t where t.tid=? and t.tplybz=? and t.tplxbz=? and t.fr=?";
return hibernateDaoHelper.findBySQL(sql, "t", Primary.class,new Object[]{tid,tplybz,tplxbz,fr}, false, -1, -1);
}
public HibernateDaoHelper getHibernateDaoHelper() {
return hibernateDaoHelper;
}
public void setHibernateDaoHelper(HibernateDaoHelper hibernateDaoHelper) {
this.hibernateDaoHelper = hibernateDaoHelper;
}
@Override
public boolean isExists(Tpzl t, List<String> names)
throws BusinessException {
// TODO Auto-generated method stub
return false;
}
@Override
public void removeEntity(Tpzl[] array) throws BusinessException {
// TODO Auto-generated method stub
}
@Override
public void updateEntity(Tpzl[] array) throws BusinessException {
// TODO Auto-generated method stub
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -