package com.atrium.hibernate.dao;

import java.util.List;

import org.hibernate.LockMode;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.atrium.hibernate.Recetas;

/**
 * A data access object (DAO) providing persistence and search support for
 * Recetas entities. Transaction control of the save(), update() and delete()
 * operations can directly support Spring container-managed transactions or they
 * can be augmented to handle user-managed Spring transactions. Each of these
 * methods provides additional information for how to configure it for the
 * desired type of transaction control.
 * 
 * @see com.atrium.hibernate.Recetas
 * @author MyEclipse Persistence Tools
 */
public class RecetasDAO extends HibernateDaoSupport {
	private static final Logger log = LoggerFactory.getLogger(RecetasDAO.class);
	// property constants
	public static final String INGREDIENTE1 = "ingrediente1";
	public static final String INGREDIENTE2 = "ingrediente2";
	public static final String INGREDIENTE3 = "ingrediente3";
	public static final String INGREDIENTE4 = "ingrediente4";
	public static final String INGREDIENTE5 = "ingrediente5";
	public static final String INGREDIENTE6 = "ingrediente6";
	public static final String INGREDIENTE7 = "ingrediente7";
	public static final String INGREDIENTE8 = "ingrediente8";
	public static final String INGREDIENTE9 = "ingrediente9";
	public static final String INGREDIENTE10 = "ingrediente10";
	public static final String INGREDIENTE11 = "ingrediente11";
	public static final String INGREDIENTE12 = "ingrediente12";
	public static final String INGREDIENTE13 = "ingrediente13";
	public static final String INGREDIENTE14 = "ingrediente14";
	public static final String INGREDIENTE15 = "ingrediente15";
	public static final String VINCULO = "vinculo";

	protected void initDao() {
		// do nothing
	}

	public void save(Recetas transientInstance) {
		log.debug("saving Recetas instance");
		try {
			getHibernateTemplate().save(transientInstance);
			log.debug("save successful");
		} catch (RuntimeException re) {
			log.error("save failed", re);
			throw re;
		}
	}

	public void delete(Recetas persistentInstance) {
		log.debug("deleting Recetas instance");
		try {
			getHibernateTemplate().delete(persistentInstance);
			log.debug("delete successful");
		} catch (RuntimeException re) {
			log.error("delete failed", re);
			throw re;
		}
	}

	public Recetas findById(java.lang.String id) {
		log.debug("getting Recetas instance with id: " + id);
		try {
			Recetas instance = (Recetas) getHibernateTemplate().get(
					"com.atrium.hibernate.Recetas", id);
			return instance;
		} catch (RuntimeException re) {
			log.error("get failed", re);
			throw re;
		}
	}

	public List findByExample(Recetas instance) {
		log.debug("finding Recetas instance by example");
		try {
			List results = getHibernateTemplate().findByExample(instance);
			log.debug("find by example successful, result size: "
					+ results.size());
			return results;
		} catch (RuntimeException re) {
			log.error("find by example failed", re);
			throw re;
		}
	}

	public List findByProperty(String propertyName, Object value) {
		log.debug("finding Recetas instance with property: " + propertyName
				+ ", value: " + value);
		try {
			String queryString = "from Recetas as model where model."
					+ propertyName + "= ?";
			return getHibernateTemplate().find(queryString, value);
		} catch (RuntimeException re) {
			log.error("find by property name failed", re);
			throw re;
		}
	}

	public List findByIngrediente1(Object ingrediente1) {
		return findByProperty(INGREDIENTE1, ingrediente1);
	}

	public List findByIngrediente2(Object ingrediente2) {
		return findByProperty(INGREDIENTE2, ingrediente2);
	}

	public List findByIngrediente3(Object ingrediente3) {
		return findByProperty(INGREDIENTE3, ingrediente3);
	}

	public List findByIngrediente4(Object ingrediente4) {
		return findByProperty(INGREDIENTE4, ingrediente4);
	}

	public List findByIngrediente5(Object ingrediente5) {
		return findByProperty(INGREDIENTE5, ingrediente5);
	}

	public List findByIngrediente6(Object ingrediente6) {
		return findByProperty(INGREDIENTE6, ingrediente6);
	}

	public List findByIngrediente7(Object ingrediente7) {
		return findByProperty(INGREDIENTE7, ingrediente7);
	}

	public List findByIngrediente8(Object ingrediente8) {
		return findByProperty(INGREDIENTE8, ingrediente8);
	}

	public List findByIngrediente9(Object ingrediente9) {
		return findByProperty(INGREDIENTE9, ingrediente9);
	}

	public List findByIngrediente10(Object ingrediente10) {
		return findByProperty(INGREDIENTE10, ingrediente10);
	}

	public List findByIngrediente11(Object ingrediente11) {
		return findByProperty(INGREDIENTE11, ingrediente11);
	}

	public List findByIngrediente12(Object ingrediente12) {
		return findByProperty(INGREDIENTE12, ingrediente12);
	}

	public List findByIngrediente13(Object ingrediente13) {
		return findByProperty(INGREDIENTE13, ingrediente13);
	}

	public List findByIngrediente14(Object ingrediente14) {
		return findByProperty(INGREDIENTE14, ingrediente14);
	}

	public List findByIngrediente15(Object ingrediente15) {
		return findByProperty(INGREDIENTE15, ingrediente15);
	}

	public List findByVinculo(Object vinculo) {
		return findByProperty(VINCULO, vinculo);
	}

	public List findAll() {
		log.debug("finding all Recetas instances");
		try {
			String queryString = "from Recetas";
			return getHibernateTemplate().find(queryString);
		} catch (RuntimeException re) {
			log.error("find all failed", re);
			throw re;
		}
	}

	public Recetas merge(Recetas detachedInstance) {
		log.debug("merging Recetas instance");
		try {
			Recetas result = (Recetas) getHibernateTemplate().merge(
					detachedInstance);
			log.debug("merge successful");
			return result;
		} catch (RuntimeException re) {
			log.error("merge failed", re);
			throw re;
		}
	}

	public void attachDirty(Recetas instance) {
		log.debug("attaching dirty Recetas instance");
		try {
			getHibernateTemplate().saveOrUpdate(instance);
			log.debug("attach successful");
		} catch (RuntimeException re) {
			log.error("attach failed", re);
			throw re;
		}
	}

	public void attachClean(Recetas instance) {
		log.debug("attaching clean Recetas instance");
		try {
			getHibernateTemplate().lock(instance, LockMode.NONE);
			log.debug("attach successful");
		} catch (RuntimeException re) {
			log.error("attach failed", re);
			throw re;
		}
	}

	public static RecetasDAO getFromApplicationContext(ApplicationContext ctx) {
		return (RecetasDAO) ctx.getBean("RecetasDAO");
	}

	
}