📄 managelogimpl.java
字号:
/*
* Created 2005-11-30
* Last modified on 2007-11-3
* Powered by YeQiangWei.com
*/
package com.yeqiangwei.club.dao.hibernate.impl;
import java.util.List;
import org.hibernate.HibernateException;
import com.yeqiangwei.club.dao.ManageLogDAO;
import com.yeqiangwei.club.dao.hibernate.support.HibernateFacade;
import com.yeqiangwei.club.dao.hibernate.support.HibernateProvider;
import com.yeqiangwei.club.dao.model.ManageLog;
import com.yeqiangwei.club.exception.DAOException;
import com.yeqiangwei.club.param.ManageLogParameter;
public class ManageLogImpl implements ManageLogDAO{
private static final String FIND_MANAGELOGID = "select * from ManageLog where manageLogId=?";
private static final String DELETES_MANAGELOGID = "delete from ManageLog where manageLogId in (:ids)";
private static final String DELETE_MANAGELOGID = "delete from ManageLog where manageLogId=?";
private static final String DELETE_TOPICID = "delete from ManageLog where topicId=?";
private static final String DELETE_REPLYID = "delete from ManageLog where replyId=?";
public int deleteByTopicId(int topicId) throws DAOException {
HibernateFacade<ManageLog> facade = new HibernateFacade<ManageLog>();
facade.createQuery(DELETE_TOPICID);
facade.setInt(0,topicId);
try{
return facade.executeUpdate();
}catch(HibernateException e){
throw new DAOException(e);
}
}
public int deleteByReplyId(int replyId) throws DAOException {
HibernateFacade<ManageLog> facade = new HibernateFacade<ManageLog>();
facade.createQuery(DELETE_REPLYID);
facade.setInt(0,replyId);
try{
return facade.executeUpdate();
}catch(HibernateException e){
throw new DAOException(e);
}
}
public void create(ManageLog item) throws DAOException {
HibernateProvider<ManageLog> facade = new HibernateFacade<ManageLog>();
try{
facade.save(item);
}catch(HibernateException e){
throw new DAOException(e);
}
}
public void update(ManageLog item) throws DAOException {
HibernateProvider<ManageLog> facade = new HibernateFacade<ManageLog>();
try{
facade.update(item);
}catch(HibernateException e){
throw new DAOException(e);
}
}
public int delete(ManageLog item) throws DAOException {
HibernateProvider<ManageLog> facade = new HibernateFacade<ManageLog>();
facade.createQuery(DELETE_MANAGELOGID);
facade.setInt(0, item.getManageLogId());
try{
return facade.executeUpdate();
}catch(HibernateException e){
throw new DAOException(e);
}
}
public int delete(List<Integer> ids) throws DAOException {
HibernateProvider<ManageLog> facade = new HibernateFacade<ManageLog>();
facade.createQuery(DELETES_MANAGELOGID);
facade.setParameterList("ids",ids);
try{
return facade.executeUpdate();
}catch(HibernateException e){
throw new DAOException(e);
}
}
public ManageLog findById(int id) {
HibernateProvider<ManageLog> facade = new HibernateFacade<ManageLog>();
facade.createQuery(FIND_MANAGELOGID);
facade.setInt(0, id);
return facade.uniqueResult();
}
public List<ManageLog> findByParameter(ManageLogParameter param) {
StringBuffer hql = new StringBuffer();
hql.append("from ManageLog where manageLogId>0 ");
if(param.getTopicId()!=null){
hql.append(" and topicId=");
hql.append(param.getTopicId().intValue());
}
if(param.getReplyId()!=null){
hql.append(" and replyId=");
hql.append(param.getReplyId().intValue());
}
if(param.getIsList()!=null){
hql.append(" and isList=:isList");
}
HibernateProvider<ManageLog> facade = new HibernateFacade<ManageLog>();
facade.createQuery(hql);
if(param.getIsList()!=null){
facade.setBoolean("isList",param.getIsList().booleanValue());
}
facade.setFirstResult(param.getPagination().getStartRow());
facade.setMaxResults(param.getPagination().getEndRow());
List<ManageLog> list = facade.executeQuery();
return list;
}
public long countByParameter(ManageLogParameter param) {
StringBuffer hql = new StringBuffer();
hql.append("select count(manageLogId) from ManageLog where manageLogId>0 ");
if(param.getTopicId()!=null){
hql.append(" and topicId=");
hql.append(param.getTopicId().intValue());
}
if(param.getReplyId()!=null){
hql.append(" and replyId=");
hql.append(param.getReplyId().intValue());
}
if(param.getIsList()!=null){
hql.append(" and isList=:isList");
}
HibernateProvider<ManageLog> facade = new HibernateFacade<ManageLog>();
facade.createQuery(hql);
if(param.getIsList()!=null){
facade.setBoolean("isList",param.getIsList().booleanValue());
}
facade.setCacheable(true);
return facade.resultTotal();
}
public List<ManageLog> findAll(ManageLogParameter param) {
return null;
}
public long countAll(ManageLogParameter param) {
return 0;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -