
package servicio;

import entidad.Categoria;
import entidad.Trama;

import java.util.List;
import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.criterion.MatchMode;
import org.hibernate.criterion.Restrictions;


public class ServicioCategoria extends AbstractFacade<Categoria> {

    public ServicioCategoria() {super(Categoria.class);}
 
    public List<Categoria> search(String m) {
        Session openSession = HibernateUtil.getSessionFactory().openSession();
        final Criteria createCriteria = openSession.createCriteria(Categoria.class);
        createCriteria.add(Restrictions.like("CatNom", m, MatchMode.ANYWHERE));
        List<Categoria> get = createCriteria.list();
        openSession.close();
        return get;
    }     
    public List<Categoria> indice(String i) {
        Session openSession = HibernateUtil.getSessionFactory().openSession();
        final Criteria createCriteria = openSession.createCriteria(Categoria.class);
        createCriteria.add(Restrictions.like("CatNom", i, MatchMode.ANYWHERE));
        List<Categoria> get = createCriteria.list();
        openSession.close();
        return get;
    }

    //CATEGORIA
    
    public List<Categoria> findAll() {return super.findAll();}
    public void save(Categoria cat) {super.createEdit(cat);}
    public void remove(int noca) {
        final Categoria find = super.find(noca);
        if (find!=null){
        super.remove(find);}
    }
    public Categoria find (int noca) {
        return super.find(noca);
    }
    
    //TRAMA
   
    
}
