Package project.dao.authorization

Source Code of project.dao.authorization.PropertiesDAOImpl

package project.dao.authorization;

import java.util.List;

import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Restrictions;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import project.entities.authorization.Properties;
import project.entities.authorization.User;

public class PropertiesDAOImpl extends HibernateDaoSupport implements
    PropertiesDAO {

  @Override
  public Properties createProperties(int role, int user, boolean value) {
    Properties properties = new Properties(role, user, value);
    return (Properties) getHibernateTemplate().save(properties);
  }

  @Override
  public Properties createProperties(Properties properties) {
    return (Properties) getHibernateTemplate().save(properties);
  }

  @Override
  public void removeProperties(Properties properties) {
    getHibernateTemplate().delete(properties);

  }

  @Override
  public void updateProperties(Properties properties) {
    getHibernateTemplate().saveOrUpdate(properties);
  }

  @Override
  public List<Properties> findProperties(int user, boolean value) {
    DetachedCriteria criteria = DetachedCriteria.forClass(Properties.class);
    criteria.add(Restrictions.and(Restrictions.eq("user", user),
        Restrictions.eq("value", value)));
    List<Properties> properties = getHibernateTemplate().findByCriteria(criteria);
    if (properties.isEmpty())
      return null;
    else
      return properties;
  }

}
TOP

Related Classes of project.dao.authorization.PropertiesDAOImpl

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.