SortHibernateDAO.java
资源名称:Myblog.rar [点击查看]
上传用户:wlfwy2004
上传日期:2016-12-12
资源大小:33978k
文件大小:2k
源码类别:
Jsp/Servlet
开发平台:
Java
- package com.opensource.blog.dao.hibernate;
- import org.springframework.orm.hibernate3.support.*;
- import com.opensource.blog.dao.SortDAO;
- import com.opensource.blog.model.Sort;
- import java.util.List;
- public class SortHibernateDAO
- extends HibernateDaoSupport implements SortDAO {
- private static final String LOAD_BY_ID_BLOGID = "from Sort where id = ? and blogid = ?";
- private static final String GET_NUM_BY_BLOGID = "select count(*) from Sort where blogid = ?";
- private static final String LOADS_BY_BLOGID = "from Sort where blogid = ? order by id desc";
- public SortHibernateDAO() {
- super();
- }
- /**
- *
- * @param sort Sort
- * @return Sort
- * @todo Implement this com.opensource.blog.dao.SortDAO method
- */
- public Sort saveSort(Sort sort) {
- this.getHibernateTemplate().saveOrUpdate(sort);
- return sort;
- }
- /**
- *
- * @param id long
- * @param blogID long
- * @return Sort
- * @todo Implement this com.opensource.blog.dao.SortDAO method
- */
- public Sort findSortByID_BlogID(long id, long blogID) {
- Object[] o = {
- new Long(id), new Long(blogID)};
- List l = this.getHibernateTemplate().find(LOAD_BY_ID_BLOGID, o);
- if (l == null || l.isEmpty()) {
- return null;
- }
- else {
- return (Sort) l.get(0);
- }
- }
- /**
- *
- * @param blogID long
- * @return int
- * @todo Implement this com.opensource.blog.dao.SortDAO method
- */
- public int getSortCountByBlogID(long blogID) {
- List l = this.getHibernateTemplate().find(GET_NUM_BY_BLOGID, new Long(blogID));
- if (l == null || l.isEmpty()) {
- return 0;
- }
- else {
- return ( (Integer) l.get(0)).intValue();
- }
- }
- /**
- *
- * @param blogID long
- * @return List
- * @todo Implement this com.opensource.blog.dao.SortDAO method
- */
- public List findSortsByBlogID(long blogID) {
- return this.getHibernateTemplate().find(LOADS_BY_BLOGID, new Long(blogID));
- }
- /**
- *
- * @param sort Sort
- */
- public void removeSort(Sort sort) {
- this.getHibernateTemplate().delete(sort);
- }
- }