Package com.jeecms.cms.dao.assist.impl

Source Code of com.jeecms.cms.dao.assist.impl.CmsFriendlinkDaoImpl

package com.jeecms.cms.dao.assist.impl;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.jeecms.cms.dao.assist.CmsFriendlinkDao;
import com.jeecms.cms.entity.assist.CmsFriendlink;
import com.jeecms.common.hibernate3.Finder;
import com.jeecms.common.hibernate3.HibernateBaseDao;

@Repository
public class CmsFriendlinkDaoImpl extends
    HibernateBaseDao<CmsFriendlink, Integer> implements CmsFriendlinkDao {
  @SuppressWarnings("unchecked")
  public List<CmsFriendlink> getList(Integer siteId, Integer ctgId,
      Boolean enabled) {
    Finder f = Finder.create("from CmsFriendlink bean where 1=1");
    if (enabled != null) {
      f.append(" and bean.enabled=:enabled");
      f.setParam("enabled", enabled);
    }
    if (siteId != null) {
      f.append(" and bean.site.id=:siteId");
      f.setParam("siteId", siteId);
    }
    if (ctgId != null) {
      f.append(" and bean.category.id=:ctgId");
      f.setParam("ctgId", ctgId);
    }
    f.append(" order by bean.priority asc");
    return find(f);
  }

  public int countByCtgId(Integer ctgId) {
    String hql = "select count(*) from CmsFriendlink bean where bean.category.id=:ctgId";
    return ((Number) getSession().createQuery(hql).setParameter("ctgId",
        ctgId).iterate().next()).intValue();
  }

  public CmsFriendlink findById(Integer id) {
    CmsFriendlink entity = get(id);
    return entity;
  }

  public CmsFriendlink save(CmsFriendlink bean) {
    getSession().save(bean);
    return bean;
  }

  public CmsFriendlink deleteById(Integer id) {
    CmsFriendlink entity = super.get(id);
    if (entity != null) {
      getSession().delete(entity);
    }
    return entity;
  }

  @Override
  protected Class<CmsFriendlink> getEntityClass() {
    return CmsFriendlink.class;
  }
}
TOP

Related Classes of com.jeecms.cms.dao.assist.impl.CmsFriendlinkDaoImpl

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.