LinksHibernateDAO.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.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);
- }
- }