/*
 * This class is autogenerated if it does not exists. It may be modified.
 * Copyright: (c) Reinders Posters
 * Modified:  $Date: 2007/07/31 14:41:10 $
 */

package nl.reinders.bm;

import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.EntityManager;
import javax.persistence.Query;

/**
 * A JPA entity class for currencytable.
 * @version    $Revision: 1.4 $
 * @author     $Author: toeukpap $
 */
@Entity
@Table(name="currencytable")
public class Currency extends nl.reinders.bm.generated.Currency
implements java.io.Serializable
{
	static final long serialVersionUID = 0;
	static final String SOURCECODE_VERSION = "$Revision: 1.4 $";
	static org.apache.log4j.Logger log4j = org.apache.log4j.Logger.getLogger(Currency.class.getName());

	// =========================================================================================
	// DAO

	/**
	 * find all entities ordered by
	 */
	static public java.util.List<nl.reinders.bm.Currency> findAllOrderedByDescription()
	{
		return findAllOrderedBy("iDescription");
	}

	// =========================================================================================
	// DAO

	/**
	 * @param currencynr
	 */
	static public nl.reinders.bm.Currency findByLabel(String label)
	{
		EntityManager lEntityManager = org.tbee.util.jpa.EntityManagerFinder.findEntityManager();
		if (log4j.isDebugEnabled()) log4j.debug("Using EM #" + Integer.toHexString( lEntityManager.hashCode() ) );
		Query lQuery = lEntityManager.createQuery("select t from Currency t where t.iLabel=:label");
		lQuery.setParameter("label", label);
		java.util.List<nl.reinders.bm.Currency> lList = lQuery.getResultList();
	    if (lList.size() == 0) return null;
	    return lList.get(0);
	}

}
