package es.dalocar.software.daos;

// Generated 03-may-2010 23:15:26 by Hibernate Tools 3.2.4.GA

import java.util.List;

import org.apache.log4j.Logger;
import org.hibernate.LockMode;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import es.dalocar.software.beans.Amortizacion;

/**
 * Home object for domain model class Amortizacion.
 * @see es.dalocar.software.beans.Amortizacion
 * @author Hibernate Tools
 */
public class AmortizacionDAO extends HibernateDaoSupport {

	private static final Logger log = Logger.getLogger(AmortizacionDAO.class);
	private static final boolean DEBUG = log.isDebugEnabled();

	
	public void persist(Amortizacion transientInstance) {
		log.debug("persisting Amortizacion instance");
		try {
			getHibernateTemplate().persist(transientInstance);
			log.debug("persist successful");
		} catch (RuntimeException re) {
			log.error("persist failed", re);
			throw re;
		}
	}
	
	public void saveOrUpdate(Amortizacion transientInstance) {
		log.debug("persisting Amortizacion instance");
		try {
			getHibernateTemplate().saveOrUpdate(transientInstance);
			log.debug("persist successful");
		} catch (RuntimeException re) {
			log.error("persist failed", re);
			throw re;
		}
	}

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

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

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

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

	public Amortizacion findById(es.dalocar.software.beans.AmortizacionId id) {
		log.debug("getting Amortizacion instance with id: " + id);
		try {
			Amortizacion instance = (Amortizacion)getHibernateTemplate().get(
							"es.dalocar.software.beans.Amortizacion", id);
			if (instance == null) {
				log.debug("get successful, no instance found");
			} else {
				log.debug("get successful, instance found");
			}
			return instance;
		} catch (RuntimeException re) {
			log.error("get failed", re);
			throw re;
		}
	}

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

	/**
	 * @param instance
	 * @return
	 */
	public List findAll() {
		if (DEBUG)
			log.debug("finding Factura instance by example");
		try {
			List results = getHibernateTemplate().find("from Factura");
			if (DEBUG)
				log.debug("find all, result size: " + results.size());
			return results;
		} catch (RuntimeException re) {
			log.error("find by example failed", re);
			throw re;
		}
	}
}
