/*
 * 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 license.
 * @version    $Revision$
 * @author     $Author$
 */
@MappedSuperclass
abstract public class License extends nl.reinders.bm.AbstractBean
implements java.io.Serializable
         , java.lang.Cloneable
         , Comparable<nl.reinders.bm.License>
{
	static final long serialVersionUID = 0;
	static final String SOURCECODE_VERSION = "$Revision$";
	static org.apache.log4j.Logger log4j = org.apache.log4j.Logger.getLogger(License.class.getName());

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

	/** LicenseArticlesWhereIAmLicense*/
	public void addLicenseArticlesWhereIAmLicense(nl.reinders.bm.LicenseArticle value)
	{
		if (value != null && !iLicenseArticlesWhereIAmLicense.contains(value))
		{
			iLicenseArticlesWhereIAmLicense.add(value);
			value.setLicense( (nl.reinders.bm.License)this);
		}
	}
	public void removeLicenseArticlesWhereIAmLicense(nl.reinders.bm.LicenseArticle value)
	{
		if (value != null && iLicenseArticlesWhereIAmLicense.contains(value))
		{
			iLicenseArticlesWhereIAmLicense.remove(value);
			value.setLicense( (nl.reinders.bm.License)null );
		}
	}
	public java.util.List<nl.reinders.bm.LicenseArticle> getLicenseArticlesWhereIAmLicense() { return iLicenseArticlesWhereIAmLicense; }
	@OneToMany(mappedBy = "iLicense", fetch = FetchType.LAZY, targetEntity = nl.reinders.bm.LicenseArticle.class, cascade = {CascadeType.PERSIST, CascadeType.REFRESH, CascadeType.MERGE} )
	private java.util.List<nl.reinders.bm.LicenseArticle> iLicenseArticlesWhereIAmLicense = new java.util.ArrayList<nl.reinders.bm.LicenseArticle>();

	/** LicensePaymentsWhereIAmLicense*/
	public void addLicensePaymentsWhereIAmLicense(nl.reinders.bm.LicensePayment value)
	{
		if (value != null && !iLicensePaymentsWhereIAmLicense.contains(value))
		{
			iLicensePaymentsWhereIAmLicense.add(value);
			value.setLicense( (nl.reinders.bm.License)this);
		}
	}
	public void removeLicensePaymentsWhereIAmLicense(nl.reinders.bm.LicensePayment value)
	{
		if (value != null && iLicensePaymentsWhereIAmLicense.contains(value))
		{
			iLicensePaymentsWhereIAmLicense.remove(value);
			value.setLicense( (nl.reinders.bm.License)null );
		}
	}
	public java.util.List<nl.reinders.bm.LicensePayment> getLicensePaymentsWhereIAmLicense() { return iLicensePaymentsWhereIAmLicense; }
	@OneToMany(mappedBy = "iLicense", fetch = FetchType.LAZY, targetEntity = nl.reinders.bm.LicensePayment.class, cascade = {CascadeType.PERSIST, CascadeType.REFRESH, CascadeType.MERGE} )
	private java.util.List<nl.reinders.bm.LicensePayment> iLicensePaymentsWhereIAmLicense = new java.util.ArrayList<nl.reinders.bm.LicensePayment>();


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

	/** Currency */
	public nl.reinders.bm.Currency getCurrency() { return iCurrency; }
	public void setCurrency(nl.reinders.bm.Currency value)
	{
		if (value == iCurrency) return; // optimalisation and prevent looping
		try
		{
			nl.reinders.bm.Currency lValue = iCurrency;
			fireVetoableChange(CURRENCY_PROPERTY_ID, lValue, value);
			if (lValue != null) lValue.removeLicensesWhereIAmCurrency( (nl.reinders.bm.License)this );
			iCurrency = value;
			if (value != null) value.addLicensesWhereIAmCurrency( (nl.reinders.bm.License)this );
			firePropertyChange(CURRENCY_PROPERTY_ID, lValue, value);
		}
		catch (java.beans.PropertyVetoException e) { throw new java.lang.IllegalArgumentException("Value vetoed: " + e.getMessage()); }
	}
	@ManyToOne(fetch = FetchType.LAZY, targetEntity = nl.reinders.bm.Currency.class, cascade = {CascadeType.PERSIST, CascadeType.REFRESH, CascadeType.MERGE} ) @JoinColumn(name="currencynr") 
	private nl.reinders.bm.Currency iCurrency;
	final static public String CURRENCY_PROPERTY_ID = "currency";
	final static public Class CURRENCY_PROPERTY_CLASS = nl.reinders.bm.Currency.class;
	final static public String CURRENCY_NAME = "Currency"; // with this ID you can access the internationalization
	// to make IN queryies possible
	@Column(name="currencynr", insertable=false, updatable=false)
	private java.math.BigDecimal iCurrencynr = null;

	/** Relation */
	public nl.reinders.bm.Relation getRelation() { return iRelation; }
	public void setRelation(nl.reinders.bm.Relation value)
	{
		if (value == iRelation) return; // optimalisation and prevent looping
		try
		{
			nl.reinders.bm.Relation lValue = iRelation;
			fireVetoableChange(RELATION_PROPERTY_ID, lValue, value);
			if (lValue != null) lValue.removeLicensesWhereIAmRelation( (nl.reinders.bm.License)this );
			iRelation = value;
			if (value != null) value.addLicensesWhereIAmRelation( (nl.reinders.bm.License)this );
			firePropertyChange(RELATION_PROPERTY_ID, lValue, value);
		}
		catch (java.beans.PropertyVetoException e) { throw new java.lang.IllegalArgumentException("Value vetoed: " + e.getMessage()); }
	}
	@ManyToOne(fetch = FetchType.LAZY, targetEntity = nl.reinders.bm.Relation.class, cascade = {CascadeType.PERSIST, CascadeType.REFRESH, CascadeType.MERGE} ) @JoinColumn(name="relationnr") 
	private nl.reinders.bm.Relation iRelation;
	final static public String RELATION_PROPERTY_ID = "relation";
	final static public Class RELATION_PROPERTY_CLASS = nl.reinders.bm.Relation.class;
	final static public String RELATION_NAME = "Relation"; // with this ID you can access the internationalization
	// to make IN queryies possible
	@Column(name="relationnr", insertable=false, updatable=false)
	private java.math.BigDecimal iRelationnr = null;



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

	/** Licensenr */
	public Integer getLicensenr() { return iLicensenr; }
	public void setLicensenr(Integer value)
	{
		try
		{
			Integer lValue = iLicensenr;
			if (log4j.isDebugEnabled()) log4j.debug("setLicensenr: " + lValue + " -> " + value);
			fireVetoableChange(LICENSENR_PROPERTY_ID, lValue, value);
			iLicensenr = value;
			firePropertyChange(LICENSENR_PROPERTY_ID, lValue, value);
		}
		catch (java.beans.PropertyVetoException e) { throw new java.lang.IllegalArgumentException("Value vetoed: " + e.getMessage()); }
	}
	@Id @GeneratedValue(generator="license.licensenr", strategy=GenerationType.TABLE) @TableGenerator( name="license.licensenr", pkColumnValue="licensenr", table="sequence", pkColumnName="seq_name", valueColumnName="seq_count", initialValue=1, allocationSize=1) @Column(name="licensenr")
	private Integer iLicensenr = null;
	final static public String LICENSENR_PROPERTY_ID = "licensenr";
	final static public Class LICENSENR_PROPERTY_CLASS = Integer.class;
	final static public String LICENSENR_NAME = "Licensenr"; // with this ID you can access the internationalization

	/** Startdate */
	public java.util.Calendar getStartdate() { return iStartdate; }
	public void setStartdate(java.util.Calendar value)
	{
		try
		{
			java.util.Calendar lValue = iStartdate;
			if (log4j.isDebugEnabled()) log4j.debug("setStartdate: " + lValue + " -> " + value);
			fireVetoableChange(STARTDATE_PROPERTY_ID, lValue, value);
			iStartdate = value;
			firePropertyChange(STARTDATE_PROPERTY_ID, lValue, value);
		}
		catch (java.beans.PropertyVetoException e) { throw new java.lang.IllegalArgumentException("Value vetoed: " + e.getMessage()); }
	}
	@Temporal(TemporalType.TIMESTAMP) @Column(name="startdate")
	private java.util.Calendar iStartdate = null;
	final static public String STARTDATE_PROPERTY_ID = "startdate";
	final static public Class STARTDATE_PROPERTY_CLASS = java.util.Calendar.class;
	final static public String STARTDATE_NAME = "Startdate"; // with this ID you can access the internationalization

	/** Enddate */
	public java.util.Calendar getEnddate() { return iEnddate; }
	public void setEnddate(java.util.Calendar value)
	{
		try
		{
			java.util.Calendar lValue = iEnddate;
			if (log4j.isDebugEnabled()) log4j.debug("setEnddate: " + lValue + " -> " + value);
			fireVetoableChange(ENDDATE_PROPERTY_ID, lValue, value);
			iEnddate = value;
			firePropertyChange(ENDDATE_PROPERTY_ID, lValue, value);
		}
		catch (java.beans.PropertyVetoException e) { throw new java.lang.IllegalArgumentException("Value vetoed: " + e.getMessage()); }
	}
	@Temporal(TemporalType.TIMESTAMP) @Column(name="enddate")
	private java.util.Calendar iEnddate = null;
	final static public String ENDDATE_PROPERTY_ID = "enddate";
	final static public Class ENDDATE_PROPERTY_CLASS = java.util.Calendar.class;
	final static public String ENDDATE_NAME = "Enddate"; // with this ID you can access the internationalization

	/** RoyaltyPercentage */
	public java.math.BigDecimal getRoyaltyPercentage() { return iRoyaltyPercentage; }
	public void setRoyaltyPercentage(java.math.BigDecimal value)
	{
		try
		{
			java.math.BigDecimal lValue = iRoyaltyPercentage;
			if (log4j.isDebugEnabled()) log4j.debug("setRoyaltyPercentage: " + lValue + " -> " + value);
			fireVetoableChange(ROYALTYPERCENTAGE_PROPERTY_ID, lValue, value);
			iRoyaltyPercentage = value;
			firePropertyChange(ROYALTYPERCENTAGE_PROPERTY_ID, lValue, value);
		}
		catch (java.beans.PropertyVetoException e) { throw new java.lang.IllegalArgumentException("Value vetoed: " + e.getMessage()); }
	}
	@Column(name="royalty_percentage")
	private java.math.BigDecimal iRoyaltyPercentage = null;
	final static public String ROYALTYPERCENTAGE_PROPERTY_ID = "royaltyPercentage";
	final static public Class ROYALTYPERCENTAGE_PROPERTY_CLASS = java.math.BigDecimal.class;
	final static public String ROYALTYPERCENTAGE_NAME = "RoyaltyPercentage"; // with this ID you can access the internationalization

	/** ExternalNumber */
	public String getExternalNumber() { return iExternalNumber; }
	public void setExternalNumber(String value)
	{
		try
		{
			String lValue = iExternalNumber;
			if (log4j.isDebugEnabled()) log4j.debug("setExternalNumber: " + lValue + " -> " + value);
			fireVetoableChange(EXTERNALNUMBER_PROPERTY_ID, lValue, value);
			iExternalNumber = value;
			firePropertyChange(EXTERNALNUMBER_PROPERTY_ID, lValue, value);
		}
		catch (java.beans.PropertyVetoException e) { throw new java.lang.IllegalArgumentException("Value vetoed: " + e.getMessage()); }
	}
	@Column(name="external_number")
	private String iExternalNumber = null;
	final static public String EXTERNALNUMBER_PROPERTY_ID = "externalNumber";
	final static public Class EXTERNALNUMBER_PROPERTY_CLASS = String.class;
	final static public String EXTERNALNUMBER_NAME = "ExternalNumber"; // with this ID you can access the internationalization

	/** Lazylock */
	public Integer getLazylock() { return iLazylock; }
	public void setLazylock(Integer value)
	{
		try
		{
			Integer lValue = iLazylock;
			if (log4j.isDebugEnabled()) log4j.debug("setLazylock: " + lValue + " -> " + value);
			fireVetoableChange(LAZYLOCK_PROPERTY_ID, lValue, value);
			iLazylock = value;
			firePropertyChange(LAZYLOCK_PROPERTY_ID, lValue, value);
		}
		catch (java.beans.PropertyVetoException e) { throw new java.lang.IllegalArgumentException("Value vetoed: " + e.getMessage()); }
	}
	@Version @Column(name="lazylock")
	private Integer iLazylock = 0;
	final static public String LAZYLOCK_PROPERTY_ID = "lazylock";
	final static public Class LAZYLOCK_PROPERTY_CLASS = Integer.class;
	final static public String LAZYLOCK_NAME = "Lazylock"; // with this ID you can access the internationalization

	/** Dwhmodified */
	public java.util.Calendar getDwhmodified() { return iDwhmodified; }
	public void setDwhmodified(java.util.Calendar value)
	{
		try
		{
			java.util.Calendar lValue = iDwhmodified;
			if (log4j.isDebugEnabled()) log4j.debug("setDwhmodified: " + lValue + " -> " + value);
			fireVetoableChange(DWHMODIFIED_PROPERTY_ID, lValue, value);
			iDwhmodified = value;
			firePropertyChange(DWHMODIFIED_PROPERTY_ID, lValue, value);
		}
		catch (java.beans.PropertyVetoException e) { throw new java.lang.IllegalArgumentException("Value vetoed: " + e.getMessage()); }
	}
	@Temporal(TemporalType.TIMESTAMP) @Column(name="dwhmodified")
	private java.util.Calendar iDwhmodified = new java.util.GregorianCalendar();
	final static public String DWHMODIFIED_PROPERTY_ID = "dwhmodified";
	final static public Class DWHMODIFIED_PROPERTY_CLASS = java.util.Calendar.class;
	final static public String DWHMODIFIED_NAME = "Dwhmodified"; // with this ID you can access the internationalization

	/** Dwhby */
	public Integer getDwhby() { return iDwhby; }
	public void setDwhby(Integer value)
	{
		try
		{
			Integer lValue = iDwhby;
			if (log4j.isDebugEnabled()) log4j.debug("setDwhby: " + lValue + " -> " + value);
			fireVetoableChange(DWHBY_PROPERTY_ID, lValue, value);
			iDwhby = value;
			firePropertyChange(DWHBY_PROPERTY_ID, lValue, value);
		}
		catch (java.beans.PropertyVetoException e) { throw new java.lang.IllegalArgumentException("Value vetoed: " + e.getMessage()); }
	}
	@Column(name="dwhby")
	private Integer iDwhby = null;
	final static public String DWHBY_PROPERTY_ID = "dwhby";
	final static public Class DWHBY_PROPERTY_CLASS = Integer.class;
	final static public String DWHBY_NAME = "Dwhby"; // with this ID you can access the internationalization

	/** Title */
	public String getTitle() { return iTitle; }
	public void setTitle(String value)
	{
		try
		{
			String lValue = iTitle;
			if (log4j.isDebugEnabled()) log4j.debug("setTitle: " + lValue + " -> " + value);
			fireVetoableChange(TITLE_PROPERTY_ID, lValue, value);
			iTitle = value;
			firePropertyChange(TITLE_PROPERTY_ID, lValue, value);
		}
		catch (java.beans.PropertyVetoException e) { throw new java.lang.IllegalArgumentException("Value vetoed: " + e.getMessage()); }
	}
	@Column(name="title")
	private String iTitle = null;
	final static public String TITLE_PROPERTY_ID = "title";
	final static public Class TITLE_PROPERTY_CLASS = String.class;
	final static public String TITLE_NAME = "Title"; // with this ID you can access the internationalization

	/** Advance */
	public java.math.BigDecimal getAdvance() { return iAdvance; }
	public void setAdvance(java.math.BigDecimal value)
	{
		try
		{
			java.math.BigDecimal lValue = iAdvance;
			if (log4j.isDebugEnabled()) log4j.debug("setAdvance: " + lValue + " -> " + value);
			fireVetoableChange(ADVANCE_PROPERTY_ID, lValue, value);
			iAdvance = value;
			firePropertyChange(ADVANCE_PROPERTY_ID, lValue, value);
		}
		catch (java.beans.PropertyVetoException e) { throw new java.lang.IllegalArgumentException("Value vetoed: " + e.getMessage()); }
	}
	@Column(name="advance")
	private java.math.BigDecimal iAdvance = new java.math.BigDecimal("0.00");
	final static public String ADVANCE_PROPERTY_ID = "advance";
	final static public Class ADVANCE_PROPERTY_CLASS = java.math.BigDecimal.class;
	final static public String ADVANCE_NAME = "Advance"; // with this ID you can access the internationalization

	/** Guarantee */
	public java.math.BigDecimal getGuarantee() { return iGuarantee; }
	public void setGuarantee(java.math.BigDecimal value)
	{
		try
		{
			java.math.BigDecimal lValue = iGuarantee;
			if (log4j.isDebugEnabled()) log4j.debug("setGuarantee: " + lValue + " -> " + value);
			fireVetoableChange(GUARANTEE_PROPERTY_ID, lValue, value);
			iGuarantee = value;
			firePropertyChange(GUARANTEE_PROPERTY_ID, lValue, value);
		}
		catch (java.beans.PropertyVetoException e) { throw new java.lang.IllegalArgumentException("Value vetoed: " + e.getMessage()); }
	}
	@Column(name="guarantee")
	private java.math.BigDecimal iGuarantee = new java.math.BigDecimal("0.00");
	final static public String GUARANTEE_PROPERTY_ID = "guarantee";
	final static public Class GUARANTEE_PROPERTY_CLASS = java.math.BigDecimal.class;
	final static public String GUARANTEE_NAME = "Guarantee"; // with this ID you can access the internationalization

	/** SellOff */
	public Integer getSellOff() { return iSellOff; }
	public void setSellOff(Integer value)
	{
		try
		{
			Integer lValue = iSellOff;
			if (log4j.isDebugEnabled()) log4j.debug("setSellOff: " + lValue + " -> " + value);
			fireVetoableChange(SELLOFF_PROPERTY_ID, lValue, value);
			iSellOff = value;
			firePropertyChange(SELLOFF_PROPERTY_ID, lValue, value);
		}
		catch (java.beans.PropertyVetoException e) { throw new java.lang.IllegalArgumentException("Value vetoed: " + e.getMessage()); }
	}
	@Column(name="sell_off")
	private Integer iSellOff = null;
	final static public String SELLOFF_PROPERTY_ID = "sellOff";
	final static public Class SELLOFF_PROPERTY_CLASS = Integer.class;
	final static public String SELLOFF_NAME = "SellOff"; // with this ID you can access the internationalization

	/** RequiredSamples */
	public Integer getRequiredSamples() { return iRequiredSamples; }
	public void setRequiredSamples(Integer value)
	{
		try
		{
			Integer lValue = iRequiredSamples;
			if (log4j.isDebugEnabled()) log4j.debug("setRequiredSamples: " + lValue + " -> " + value);
			fireVetoableChange(REQUIREDSAMPLES_PROPERTY_ID, lValue, value);
			iRequiredSamples = value;
			firePropertyChange(REQUIREDSAMPLES_PROPERTY_ID, lValue, value);
		}
		catch (java.beans.PropertyVetoException e) { throw new java.lang.IllegalArgumentException("Value vetoed: " + e.getMessage()); }
	}
	@Column(name="required_samples")
	private Integer iRequiredSamples = 0;
	final static public String REQUIREDSAMPLES_PROPERTY_ID = "requiredSamples";
	final static public Class REQUIREDSAMPLES_PROPERTY_CLASS = Integer.class;
	final static public String REQUIREDSAMPLES_NAME = "RequiredSamples"; // with this ID you can access the internationalization

	/** GeoLimit */
	public String getGeoLimit() { return iGeoLimit; }
	public void setGeoLimit(String value)
	{
		try
		{
			String lValue = iGeoLimit;
			if (log4j.isDebugEnabled()) log4j.debug("setGeoLimit: " + lValue + " -> " + value);
			fireVetoableChange(GEOLIMIT_PROPERTY_ID, lValue, value);
			iGeoLimit = value;
			firePropertyChange(GEOLIMIT_PROPERTY_ID, lValue, value);
		}
		catch (java.beans.PropertyVetoException e) { throw new java.lang.IllegalArgumentException("Value vetoed: " + e.getMessage()); }
	}
	@Column(name="geo_limit")
	private String iGeoLimit = null;
	final static public String GEOLIMIT_PROPERTY_ID = "geoLimit";
	final static public Class GEOLIMIT_PROPERTY_CLASS = String.class;
	final static public String GEOLIMIT_NAME = "GeoLimit"; // with this ID you can access the internationalization

	/** Remark */
	public String getRemark() { return iRemark; }
	public void setRemark(String value)
	{
		try
		{
			String lValue = iRemark;
			if (log4j.isDebugEnabled()) log4j.debug("setRemark: " + lValue + " -> " + value);
			fireVetoableChange(REMARK_PROPERTY_ID, lValue, value);
			iRemark = value;
			firePropertyChange(REMARK_PROPERTY_ID, lValue, value);
		}
		catch (java.beans.PropertyVetoException e) { throw new java.lang.IllegalArgumentException("Value vetoed: " + e.getMessage()); }
	}
	@Column(name="remark")
	private String iRemark = null;
	final static public String REMARK_PROPERTY_ID = "remark";
	final static public Class REMARK_PROPERTY_CLASS = String.class;
	final static public String REMARK_NAME = "Remark"; // with this ID you can access the internationalization


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

	/** clone */
	public Object clone()
	{ 
		nl.reinders.bm.License lNew = new nl.reinders.bm.License();
		lNew.setCurrency( getCurrency() ); 
		lNew.setRelation( getRelation() ); 
		lNew.setStartdate( getStartdate() ); 
		lNew.setEnddate( getEnddate() ); 
		lNew.setRoyaltyPercentage( getRoyaltyPercentage() ); 
		lNew.setExternalNumber( getExternalNumber() ); 
		// not cloning this column: lNew.setDwhmodified( getDwhmodified() ); 
		// not cloning this column: lNew.setDwhby( getDwhby() ); 
		lNew.setTitle( getTitle() ); 
		lNew.setAdvance( getAdvance() ); 
		lNew.setGuarantee( getGuarantee() ); 
		lNew.setSellOff( getSellOff() ); 
		lNew.setRequiredSamples( getRequiredSamples() ); 
		lNew.setGeoLimit( getGeoLimit() ); 
		lNew.setRemark( getRemark() ); 
		return lNew;
	}
	public nl.reinders.bm.License cloneShallow() { return (nl.reinders.bm.License)clone();}


	// =========================================================================================
	// Comparable

	/**
	 * default compare on primary key
	 */
	public int compareTo(nl.reinders.bm.License o)
	{
		if (this.getLicensenr() == null) return -1;
		if (o == null) return 1;
		return this.getLicensenr().compareTo( o.getLicensenr() );
	}


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

	/**
	 * @param licensenr
	 */
	static public nl.reinders.bm.License findByPK(Integer licensenr)
	{
		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 License t where t.iLicensenr=:licensenr");
		lQuery.setParameter("licensenr", licensenr);
		java.util.List<nl.reinders.bm.License> lList = lQuery.getResultList();
	    if (lList.size() == 0) return null;
	    return lList.get(0);
	}

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

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


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

	/**
	 *
	 */
	public boolean equals(Object o)
	{
		if (o == null) return false;
		if (!(o instanceof nl.reinders.bm.License)) return false;
		nl.reinders.bm.License lOther = (nl.reinders.bm.License)o;
		if (
			this.getLicensenr() != null && lOther.getLicensenr() != null
		)
		{
			return
				   this.getLicensenr().equals( lOther.getLicensenr() )
			;
		}
		else
			return super.equals(o);
	}



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

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


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