📄 uncommandworddaohibernate.java
字号:
package com.longtime.wap.module.cellphone.dao.hibernate;
import java.sql.SQLException;
import java.util.List;
import org.hibernate.HibernateException;
import org.hibernate.Query;
import org.hibernate.Session;
import org.springframework.orm.hibernate3.HibernateCallback;
import com.longtime.wap.common.BaseDao;
import com.longtime.wap.common.web.Page;
import com.longtime.wap.model.UncommandWord;
import com.longtime.wap.module.cellphone.common.UncommandWordQueryBean;
import com.longtime.wap.module.cellphone.dao.UncommandWordDao;
/**
* UncommandWordDao层代码实现类
*
* @author shiz
* @date Nov 15, 2007
*/
public class UncommandWordDaoHibernate extends BaseDao implements
UncommandWordDao {
/**
* 统计过滤字符数
*
* @param queryBean
* 搜索参数
* @return 过滤字符数
*/
public int retrieveUncommandWordsCount(
final UncommandWordQueryBean queryBean) {
return (Integer) getHibernateTemplate().execute(
new HibernateCallback() {
public Object doInHibernate(Session session)
throws HibernateException, SQLException {
StringBuilder hql = new StringBuilder(
"select count(*) from UncommandWord ");
Query query = session.createQuery(hql.toString());
query.setProperties(queryBean);
return query.uniqueResult();
}
});
}
/**
* 列表显示所有符合搜索条件的过滤字符数
*
* @param queryBean
* 搜索参数
* @param page
* 分页参数
* @return 过滤字符列表
*/
public List retrieveUncommandWords(final UncommandWordQueryBean queryBean,
final Page page) {
return this.getHibernateTemplate().executeFind(new HibernateCallback() {
public Object doInHibernate(Session session)
throws HibernateException, SQLException {
Query query = session.createQuery("from UncommandWord order "
+ "by uncommandWordId asc");
query.setProperties(queryBean);
return query.setFirstResult(page.getFirstResult())
.setMaxResults(page.getPageSize()).list();
}
});
}
/**
* 获取过滤字符列表
*
* @param ids
* 过滤字符编号
* @return 过滤字符列表
*/
public List retrieveUncommandWordsByIds(final String[] ids) {
return (List) this.getHibernateTemplate().executeFind(
new HibernateCallback() {
public Object doInHibernate(Session session)
throws HibernateException, SQLException {
StringBuilder hql = new StringBuilder(
"from UncommandWord where ");
for (int i = 0; i < ids.length; i++) {
hql.append("uncommandWordId=" + ids[i]);
if (i < ids.length - 1) {
hql.append(" or ");
}
}
Query query = session.createQuery(hql.toString());
return query.list();
}
});
}
/**
* 获取过滤字符信息
*
* @param id
* 过滤字符编号
* @return 过滤字符信息
*/
public UncommandWord retrieveUncommandWordById(Long id) {
return (UncommandWord) getHibernateTemplate().get(UncommandWord.class,
id);
}
/**
* 更新过滤字符信息
*
* @param uncommandWord
* 过滤字符对象
*/
public void updateUncommandWord(UncommandWord uncommandWord) {
this.getHibernateTemplate().update(uncommandWord);
}
/**
* 新增过滤字符信息
*
* @param uncommandWord
* 过滤字符对象
*/
public void createUncommandWord(UncommandWord uncommandWord) {
this.getHibernateTemplate().save(uncommandWord);
}
/**
* 删除过滤字符
*
* @param uncommandWords
* 过滤字符列表
*/
public void deleteUncommandWords(List uncommandWords) {
this.getHibernateTemplate().deleteAll(uncommandWords);
}
/**
* 通过过滤字符获得过滤字符列表
*
* @param word
* 过滤字符
* @return 过滤字符列表
*/
public List retrieveUncommandWordByWord(final String word) {
return this.getHibernateTemplate().executeFind(new HibernateCallback() {
public Object doInHibernate(Session session)
throws HibernateException, SQLException {
Query query = session
.createQuery("from UncommandWord where word= ?");
query.setString(0, word);
return query.list();
}
});
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -