/*
 * This is autogenerated and should not be modified.
 * Any changes should be made to the super class.
 * Copyright: (c) Reinders Posters
 * Modified:  $Date$
 */

package nl.reinders.bm.generated;

import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.beans.PropertyVetoException;
import java.beans.VetoableChangeListener;
import java.beans.VetoableChangeSupport;

import javax.persistence.EntityManager;
import javax.persistence.MappedSuperclass;
import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.SequenceGenerator;
import javax.persistence.TableGenerator;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Version;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.FetchType;
import javax.persistence.CascadeType;
import javax.persistence.JoinColumn;
import javax.persistence.Query;
import javax.persistence.Transient;

/**
 * A JPA entity class for _number.
 * @version    $Revision$
 * @author     $Author$
 */
@MappedSuperclass
abstract public class Number extends nl.reinders.bm.AbstractBean
implements java.io.Serializable
         , java.lang.Cloneable
{
	static final long serialVersionUID = 0;
	static final String SOURCECODE_VERSION = "$Revision$";
	static org.apache.log4j.Logger log4j = org.apache.log4j.Logger.getLogger(Number.class.getName());

	// ===============================================================================================
	// RELATIONS OneToMany


	// ===============================================================================================
	// RELATIONS ManyToOne



	// ===============================================================================================
	// PROPERTIES

	/** N */
	public Integer getN() { return iN; }
	public void setN(Integer value)
	{
		try
		{
			Integer lValue = iN;
			if (log4j.isDebugEnabled()) log4j.debug("setN: " + lValue + " -> " + value);
			fireVetoableChange(N_PROPERTY_ID, lValue, value);
			iN = value;
			firePropertyChange(N_PROPERTY_ID, lValue, value);
		}
		catch (java.beans.PropertyVetoException e) { throw new java.lang.IllegalArgumentException("Value vetoed: " + e.getMessage()); }
	}
	@Column(name="n")
	private Integer iN = null;
	final static public String N_PROPERTY_ID = "n";
	final static public Class N_PROPERTY_CLASS = Integer.class;
	final static public String N_NAME = "N"; // with this ID you can access the internationalization


	// ===============================================================================================
	// Clone

	/** clone */
	public Object clone()
	{ 
		nl.reinders.bm.Number lNew = new nl.reinders.bm.Number();
		lNew.setN( getN() ); 
		return lNew;
	}
	public nl.reinders.bm.Number cloneShallow() { return (nl.reinders.bm.Number)clone();}


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

	/**
	 */
	static public nl.reinders.bm.Number findByPK()
	{
		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 Number t where ");
		java.util.List<nl.reinders.bm.Number> lList = lQuery.getResultList();
	    if (lList.size() == 0) return null;
	    return lList.get(0);
	}

	/**
	 * find all entities
	 */
	static public java.util.List<nl.reinders.bm.Number> findAll()
	{
		return findAllOrderedBy(null);
	}

	/**
	 * find all entities ordered by
	 */
	static public java.util.List<nl.reinders.bm.Number> findAllOrderedBy(String orderedBy)
	{
		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 Number t" + (orderedBy == null ? "" : " order by t." + orderedBy) + "");
		java.util.List<nl.reinders.bm.Number> lList = lQuery.getResultList();
	    return lList;
	}


	// =========================================================================================
	// EQUALS

	/**
	 *
	 */
	public boolean equals(Object o)
	{
		return super.equals(o);
	}



	// =========================================================================================
	// CONVIENIENCE

	/**
	 *
	 */
	public String toString()
	{
		StringBuffer lStringBuffer = new StringBuffer();
		lStringBuffer.append(super.toString());
		return lStringBuffer.toString();
	}


	/**
	 * Using the Internationalization class
	 */
	static public String translate(String id)
	{
		return org.tbee.util.Internationalization.getInternationalization().translate(nl.reinders.bm.Number.class, id);
	}
}
