📄 fileuploadimpl.java
字号:
/*
* Created on 2007-4-17
* Last modified on 2007-4-17
* Powered by YeQiangWei.com
*/
package com.yeqiangwei.club.fileUpload.dao.hibernate;
import java.util.List;
import org.hibernate.HibernateException;
import com.yeqiangwei.club.dao.hibernate.support.HibernateFacade;
import com.yeqiangwei.club.exception.DAOException;
import com.yeqiangwei.club.fileUpload.FileUploadParameter;
import com.yeqiangwei.club.fileUpload.dao.FileUpload;
import com.yeqiangwei.club.fileUpload.dao.FileUploadDAO;
public class FileUploadImpl implements FileUploadDAO {
private static final String FIND_ALL = "from FileUpload order by fileUploadId desc";
private static final String COUNT_ALL = "select count(fileUploadId) from FileUpload";
private static final String FIND_FILEUPLOADID = "from FileUpload where fileUploadId=?";
private static final String DELETE_FILEUPLOADID = "delete from FileUpload where fileUploadId=?";
private static final String DELETES_FILEUPLOADID = "delete from FileUpload where fileUploadId in (:ids)";
public void create(FileUpload item) throws DAOException {
HibernateFacade<FileUpload> facade = new HibernateFacade<FileUpload>();
try{
facade.save(item);
}catch(HibernateException e){
throw new DAOException(e);
}
}
public void update(FileUpload item) throws DAOException {
HibernateFacade<FileUpload> facade = new HibernateFacade<FileUpload>();
try{
facade.update(item);
}catch(HibernateException e){
throw new DAOException(e);
}
}
public int delete(FileUpload item) throws DAOException {
HibernateFacade<FileUpload> facade = new HibernateFacade<FileUpload>();
facade.createQuery(DELETE_FILEUPLOADID);
facade.setInt(0, item.getFileUploadId());
try{
return facade.executeUpdate();
}catch(HibernateException e){
throw new DAOException(e);
}
}
public int delete(List<Integer> ids) throws DAOException {
HibernateFacade<FileUpload> facade = new HibernateFacade<FileUpload>();
facade.createQuery(DELETES_FILEUPLOADID);
facade.setParameterList("ids",ids);
try{
return facade.executeUpdate();
}catch(HibernateException e){
throw new DAOException(e);
}
}
public FileUpload findById(int id) {
HibernateFacade<FileUpload> facade = new HibernateFacade<FileUpload>();
facade.createQuery(FIND_FILEUPLOADID);
facade.setInt(0, id);
facade.setMaxResults(1);
return facade.uniqueResult();
}
public List<FileUpload> findByParameter(FileUploadParameter param) {
HibernateFacade<FileUpload> facade = new HibernateFacade<FileUpload>();
facade.createQuery(FIND_ALL);
facade.setFirstResult(param.getPagination().getStartRow());
facade.setMaxResults(param.getPagination().getEndRow());
return facade.executeQuery();
}
public long countByParameter(FileUploadParameter param) {
HibernateFacade<FileUpload> facade = new HibernateFacade<FileUpload>();
facade.createQuery(COUNT_ALL);
return facade.resultTotal();
}
public List<FileUpload> findAll(FileUploadParameter param) {
HibernateFacade<FileUpload> facade = new HibernateFacade<FileUpload>();
facade.createQuery(FIND_ALL);
facade.setFirstResult(param.getPagination().getStartRow());
facade.setMaxResults(param.getPagination().getEndRow());
return facade.executeQuery();
}
public long countAll(FileUploadParameter param) {
HibernateFacade<FileUpload> facade = new HibernateFacade<FileUpload>();
facade.createQuery(COUNT_ALL);
return facade.resultTotal();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -