Package com.finiac.dao

Source Code of com.finiac.dao.ProductDAOImpl

package com.finiac.dao;

import java.util.List;

import org.hibernate.SessionFactory;
import org.springframework.orm.hibernate3.HibernateTemplate;

import com.finiac.model.Product;

public class ProductDAOImpl implements ProductDAO {

  private HibernateTemplate hibernateTemplate;
 
  public void setSessionFactory(SessionFactory sessionFactory){
    this.hibernateTemplate = new HibernateTemplate(sessionFactory);
  }
 
  @Override
  public void addProduct(Product product) {
    hibernateTemplate.saveOrUpdate(product);

  }

  @SuppressWarnings("unchecked")
  @Override
  public List<Product> listProduct() {
    return hibernateTemplate.find("from Product where isActive = 1 order by id");
  }

  @SuppressWarnings("unchecked")
  @Override
  public List<Product> selectById(int id) {
    return hibernateTemplate.find("from Product where id="+id + " and isActive = 1");
  }

  @Override
  public void updateProduct(Product product) {
    hibernateTemplate.update(product);
  }
  @SuppressWarnings("unchecked")
  @Override
  public List<Product> autoCom(String text)
  {
    return hibernateTemplate.find("from Product where product like ? and isActive = 1", "%" + text + "%");
  }
 
}
TOP

Related Classes of com.finiac.dao.ProductDAOImpl

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.