⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 linkshibernatedao.java

📁 是一个网站的博客系统
💻 JAVA
字号:
package com.opensource.blog.dao.hibernate;

import org.springframework.orm.hibernate3.support.*;
import com.opensource.blog.dao.LinksDAO;
import com.opensource.blog.model.Links;

import java.util.List;


public class LinksHibernateDAO
    extends HibernateDaoSupport implements LinksDAO {

  private static final String LOAD_BY_ID_BLOGID = "from Links where id = ? and blogid = ?";

  private static final String GET_COUNT_BY_BLOGID_TYPE =
      "select count(*) from Links where blogid = ? and linktype = ?";

  private static final String LOADS_BY_BLOGID_TYPE = "from Links where blogid = ? and linktype = ?";

  public LinksHibernateDAO() {
    super();
  }

  /**
   *
   * @param links Links
   * @return Links
   * @todo Implement this com.opensource.blog.dao.LinksDAO method
   */
  public Links saveLinks(Links links) {
    this.getHibernateTemplate().saveOrUpdate(links);
    return links;
  }

  /**
   *
   * @param id long
   * @param blogID long
   * @return Links
   * @todo Implement this com.opensource.blog.dao.LinksDAO method
   */
  public Links findLinksByID_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 (Links) l.get(0);
    }
  }

  /**
   *
   * @param blogID long
   * @param linkType int
   * @return int
   * @todo Implement this com.opensource.blog.dao.LinksDAO method
   */
  public int getLinksCountByBlogID_Type(long blogID, int linkType) {
    Object[] o = {new Long(blogID), new Long(linkType)};
    List l = this.getHibernateTemplate().find(GET_COUNT_BY_BLOGID_TYPE, o);
    if (l == null || l.isEmpty()) {
      return 0;
    }
    else {
      return ( (Integer) l.get(0)).intValue();
    }
  }

  /**
   *
   * @param blogID long
   * @param linkType int
   * @return List
   * @todo Implement this com.opensource.blog.dao.LinksDAO method
   */
  public List findLinksByBlogID_Type(long blogID, int linkType) {
    Object[] o = {new Long(blogID), new Long(linkType)};
    return this.getHibernateTemplate().find(LOADS_BY_BLOGID_TYPE, o);
  }

  /**
   *
   * @param links Links
   * @todo Implement this com.opensource.blog.dao.LinksDAO method
   */
  public void removeLinks(Links links) {
    this.getHibernateTemplate().delete(links);
  }

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -