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

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

	/** BuyordersWhereIAmContact*/
	public void addBuyordersWhereIAmContact(nl.reinders.bm.Buyorder value)
	{
		if (value != null && !iBuyordersWhereIAmContact.contains(value))
		{
			iBuyordersWhereIAmContact.add(value);
			value.setContact( (nl.reinders.bm.Contact)this);
		}
	}
	public void removeBuyordersWhereIAmContact(nl.reinders.bm.Buyorder value)
	{
		if (value != null && iBuyordersWhereIAmContact.contains(value))
		{
			iBuyordersWhereIAmContact.remove(value);
			value.setContact( (nl.reinders.bm.Contact)null );
		}
	}
	public java.util.List<nl.reinders.bm.Buyorder> getBuyordersWhereIAmContact() { return iBuyordersWhereIAmContact; }
	@OneToMany(mappedBy = "iContact", fetch = FetchType.LAZY, targetEntity = nl.reinders.bm.Buyorder.class, cascade = {CascadeType.PERSIST, CascadeType.REFRESH, CascadeType.MERGE} )
	private java.util.List<nl.reinders.bm.Buyorder> iBuyordersWhereIAmContact = new java.util.ArrayList<nl.reinders.bm.Buyorder>();

	/** CalendarsWhereIAmContact*/
	public void addCalendarsWhereIAmContact(nl.reinders.bm.Calendar value)
	{
		if (value != null && !iCalendarsWhereIAmContact.contains(value))
		{
			iCalendarsWhereIAmContact.add(value);
			value.setContact( (nl.reinders.bm.Contact)this);
		}
	}
	public void removeCalendarsWhereIAmContact(nl.reinders.bm.Calendar value)
	{
		if (value != null && iCalendarsWhereIAmContact.contains(value))
		{
			iCalendarsWhereIAmContact.remove(value);
			value.setContact( (nl.reinders.bm.Contact)null );
		}
	}
	public java.util.List<nl.reinders.bm.Calendar> getCalendarsWhereIAmContact() { return iCalendarsWhereIAmContact; }
	@OneToMany(mappedBy = "iContact", fetch = FetchType.LAZY, targetEntity = nl.reinders.bm.Calendar.class, cascade = {CascadeType.PERSIST, CascadeType.REFRESH, CascadeType.MERGE} )
	private java.util.List<nl.reinders.bm.Calendar> iCalendarsWhereIAmContact = new java.util.ArrayList<nl.reinders.bm.Calendar>();

	/** ContacttelsWhereIAmContact*/
	public void addContacttelsWhereIAmContact(nl.reinders.bm.Contacttel value)
	{
		if (value != null && !iContacttelsWhereIAmContact.contains(value))
		{
			iContacttelsWhereIAmContact.add(value);
			value.setContact( (nl.reinders.bm.Contact)this);
		}
	}
	public void removeContacttelsWhereIAmContact(nl.reinders.bm.Contacttel value)
	{
		if (value != null && iContacttelsWhereIAmContact.contains(value))
		{
			iContacttelsWhereIAmContact.remove(value);
			value.setContact( (nl.reinders.bm.Contact)null );
		}
	}
	public java.util.List<nl.reinders.bm.Contacttel> getContacttelsWhereIAmContact() { return iContacttelsWhereIAmContact; }
	@OneToMany(mappedBy = "iContact", fetch = FetchType.LAZY, targetEntity = nl.reinders.bm.Contacttel.class, cascade = {CascadeType.PERSIST, CascadeType.REFRESH, CascadeType.MERGE} )
	private java.util.List<nl.reinders.bm.Contacttel> iContacttelsWhereIAmContact = new java.util.ArrayList<nl.reinders.bm.Contacttel>();

	/** SellordersWhereIAmContact*/
	public void addSellordersWhereIAmContact(nl.reinders.bm.Sellorder value)
	{
		if (value != null && !iSellordersWhereIAmContact.contains(value))
		{
			iSellordersWhereIAmContact.add(value);
			value.setContact( (nl.reinders.bm.Contact)this);
		}
	}
	public void removeSellordersWhereIAmContact(nl.reinders.bm.Sellorder value)
	{
		if (value != null && iSellordersWhereIAmContact.contains(value))
		{
			iSellordersWhereIAmContact.remove(value);
			value.setContact( (nl.reinders.bm.Contact)null );
		}
	}
	public java.util.List<nl.reinders.bm.Sellorder> getSellordersWhereIAmContact() { return iSellordersWhereIAmContact; }
	@OneToMany(mappedBy = "iContact", fetch = FetchType.LAZY, targetEntity = nl.reinders.bm.Sellorder.class, cascade = {CascadeType.PERSIST, CascadeType.REFRESH, CascadeType.MERGE} )
	private java.util.List<nl.reinders.bm.Sellorder> iSellordersWhereIAmContact = new java.util.ArrayList<nl.reinders.bm.Sellorder>();

	/** WebimagedownloadsWhereIAmContact*/
	public void addWebimagedownloadsWhereIAmContact(nl.reinders.bm.Webimagedownload value)
	{
		if (value != null && !iWebimagedownloadsWhereIAmContact.contains(value))
		{
			iWebimagedownloadsWhereIAmContact.add(value);
			value.setContact( (nl.reinders.bm.Contact)this);
		}
	}
	public void removeWebimagedownloadsWhereIAmContact(nl.reinders.bm.Webimagedownload value)
	{
		if (value != null && iWebimagedownloadsWhereIAmContact.contains(value))
		{
			iWebimagedownloadsWhereIAmContact.remove(value);
			value.setContact( (nl.reinders.bm.Contact)null );
		}
	}
	public java.util.List<nl.reinders.bm.Webimagedownload> getWebimagedownloadsWhereIAmContact() { return iWebimagedownloadsWhereIAmContact; }
	@OneToMany(mappedBy = "iContact", fetch = FetchType.LAZY, targetEntity = nl.reinders.bm.Webimagedownload.class, cascade = {CascadeType.PERSIST, CascadeType.REFRESH, CascadeType.MERGE} )
	private java.util.List<nl.reinders.bm.Webimagedownload> iWebimagedownloadsWhereIAmContact = new java.util.ArrayList<nl.reinders.bm.Webimagedownload>();

	/** WeblightboxsWhereIAmContact*/
	public void addWeblightboxsWhereIAmContact(nl.reinders.bm.Weblightbox value)
	{
		if (value != null && !iWeblightboxsWhereIAmContact.contains(value))
		{
			iWeblightboxsWhereIAmContact.add(value);
			value.setContact( (nl.reinders.bm.Contact)this);
		}
	}
	public void removeWeblightboxsWhereIAmContact(nl.reinders.bm.Weblightbox value)
	{
		if (value != null && iWeblightboxsWhereIAmContact.contains(value))
		{
			iWeblightboxsWhereIAmContact.remove(value);
			value.setContact( (nl.reinders.bm.Contact)null );
		}
	}
	public java.util.List<nl.reinders.bm.Weblightbox> getWeblightboxsWhereIAmContact() { return iWeblightboxsWhereIAmContact; }
	@OneToMany(mappedBy = "iContact", fetch = FetchType.LAZY, targetEntity = nl.reinders.bm.Weblightbox.class, cascade = {CascadeType.PERSIST, CascadeType.REFRESH, CascadeType.MERGE} )
	private java.util.List<nl.reinders.bm.Weblightbox> iWeblightboxsWhereIAmContact = new java.util.ArrayList<nl.reinders.bm.Weblightbox>();


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

	/** 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.removeContactsWhereIAmRelation( (nl.reinders.bm.Contact)this );
			iRelation = value;
			if (value != null) value.addContactsWhereIAmRelation( (nl.reinders.bm.Contact)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

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

	/** Name */
	public String getName() { return iName; }
	public void setName(String value)
	{
		try
		{
			String lValue = iName;
			if (log4j.isDebugEnabled()) log4j.debug("setName: " + lValue + " -> " + value);
			fireVetoableChange(NAME_PROPERTY_ID, lValue, value);
			iName = value;
			firePropertyChange(NAME_PROPERTY_ID, lValue, value);
		}
		catch (java.beans.PropertyVetoException e) { throw new java.lang.IllegalArgumentException("Value vetoed: " + e.getMessage()); }
	}
	@Column(name="name")
	private String iName = null;
	final static public String NAME_PROPERTY_ID = "name";
	final static public Class NAME_PROPERTY_CLASS = String.class;
	final static public String NAME_NAME = "Name"; // with this ID you can access the internationalization

	/** Information */
	public String getInformation() { return iInformation; }
	public void setInformation(String value)
	{
		try
		{
			String lValue = iInformation;
			if (log4j.isDebugEnabled()) log4j.debug("setInformation: " + lValue + " -> " + value);
			fireVetoableChange(INFORMATION_PROPERTY_ID, lValue, value);
			iInformation = value;
			firePropertyChange(INFORMATION_PROPERTY_ID, lValue, value);
		}
		catch (java.beans.PropertyVetoException e) { throw new java.lang.IllegalArgumentException("Value vetoed: " + e.getMessage()); }
	}
	@Column(name="information")
	private String iInformation = null;
	final static public String INFORMATION_PROPERTY_ID = "information";
	final static public Class INFORMATION_PROPERTY_CLASS = String.class;
	final static public String INFORMATION_NAME = "Information"; // 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

	/** Prefix */
	public String getPrefix() { return iPrefix; }
	public void setPrefix(String value)
	{
		try
		{
			String lValue = iPrefix;
			if (log4j.isDebugEnabled()) log4j.debug("setPrefix: " + lValue + " -> " + value);
			fireVetoableChange(PREFIX_PROPERTY_ID, lValue, value);
			iPrefix = value;
			firePropertyChange(PREFIX_PROPERTY_ID, lValue, value);
		}
		catch (java.beans.PropertyVetoException e) { throw new java.lang.IllegalArgumentException("Value vetoed: " + e.getMessage()); }
	}
	@Column(name="prefix")
	private String iPrefix = null;
	final static public String PREFIX_PROPERTY_ID = "prefix";
	final static public Class PREFIX_PROPERTY_CLASS = String.class;
	final static public String PREFIX_NAME = "Prefix"; // with this ID you can access the internationalization

	/** Webemail */
	public String getWebemail() { return iWebemail; }
	public void setWebemail(String value)
	{
		try
		{
			String lValue = iWebemail;
			if (log4j.isDebugEnabled()) log4j.debug("setWebemail: " + lValue + " -> " + value);
			fireVetoableChange(WEBEMAIL_PROPERTY_ID, lValue, value);
			iWebemail = value;
			firePropertyChange(WEBEMAIL_PROPERTY_ID, lValue, value);
		}
		catch (java.beans.PropertyVetoException e) { throw new java.lang.IllegalArgumentException("Value vetoed: " + e.getMessage()); }
	}
	@Column(name="webemail")
	private String iWebemail = null;
	final static public String WEBEMAIL_PROPERTY_ID = "webemail";
	final static public Class WEBEMAIL_PROPERTY_CLASS = String.class;
	final static public String WEBEMAIL_NAME = "Webemail"; // with this ID you can access the internationalization

	/** Webpassword */
	public String getWebpassword() { return iWebpassword; }
	public void setWebpassword(String value)
	{
		try
		{
			String lValue = iWebpassword;
			if (log4j.isDebugEnabled()) log4j.debug("setWebpassword: " + lValue + " -> " + value);
			fireVetoableChange(WEBPASSWORD_PROPERTY_ID, lValue, value);
			iWebpassword = value;
			firePropertyChange(WEBPASSWORD_PROPERTY_ID, lValue, value);
		}
		catch (java.beans.PropertyVetoException e) { throw new java.lang.IllegalArgumentException("Value vetoed: " + e.getMessage()); }
	}
	@Column(name="webpassword")
	private String iWebpassword = null;
	final static public String WEBPASSWORD_PROPERTY_ID = "webpassword";
	final static public Class WEBPASSWORD_PROPERTY_CLASS = String.class;
	final static public String WEBPASSWORD_NAME = "Webpassword"; // with this ID you can access the internationalization

	/** Newsletter */
	public Integer getNewsletter() { return iNewsletter; }
	public void setNewsletter(Integer value)
	{
		try
		{
			Integer lValue = iNewsletter;
			if (log4j.isDebugEnabled()) log4j.debug("setNewsletter: " + lValue + " -> " + value);
			fireVetoableChange(NEWSLETTER_PROPERTY_ID, lValue, value);
			iNewsletter = value;
			firePropertyChange(NEWSLETTER_PROPERTY_ID, lValue, value);
		}
		catch (java.beans.PropertyVetoException e) { throw new java.lang.IllegalArgumentException("Value vetoed: " + e.getMessage()); }
	}
	@Column(name="newsletter")
	private Integer iNewsletter = 0;
	final static public String NEWSLETTER_PROPERTY_ID = "newsletter";
	final static public Class NEWSLETTER_PROPERTY_CLASS = Integer.class;
	final static public String NEWSLETTER_NAME = "Newsletter"; // with this ID you can access the internationalization

	/** Billpassword */
	public String getBillpassword() { return iBillpassword; }
	public void setBillpassword(String value)
	{
		try
		{
			String lValue = iBillpassword;
			if (log4j.isDebugEnabled()) log4j.debug("setBillpassword: " + lValue + " -> " + value);
			fireVetoableChange(BILLPASSWORD_PROPERTY_ID, lValue, value);
			iBillpassword = value;
			firePropertyChange(BILLPASSWORD_PROPERTY_ID, lValue, value);
		}
		catch (java.beans.PropertyVetoException e) { throw new java.lang.IllegalArgumentException("Value vetoed: " + e.getMessage()); }
	}
	@Column(name="billpassword")
	private String iBillpassword = null;
	final static public String BILLPASSWORD_PROPERTY_ID = "billpassword";
	final static public Class BILLPASSWORD_PROPERTY_CLASS = String.class;
	final static public String BILLPASSWORD_NAME = "Billpassword"; // with this ID you can access the internationalization

	/** Accessrelationgroup */
	public Integer getAccessrelationgroup() { return iAccessrelationgroup; }
	public void setAccessrelationgroup(Integer value)
	{
		try
		{
			Integer lValue = iAccessrelationgroup;
			if (log4j.isDebugEnabled()) log4j.debug("setAccessrelationgroup: " + lValue + " -> " + value);
			fireVetoableChange(ACCESSRELATIONGROUP_PROPERTY_ID, lValue, value);
			iAccessrelationgroup = value;
			firePropertyChange(ACCESSRELATIONGROUP_PROPERTY_ID, lValue, value);
		}
		catch (java.beans.PropertyVetoException e) { throw new java.lang.IllegalArgumentException("Value vetoed: " + e.getMessage()); }
	}
	@Column(name="accessrelationgroup")
	private Integer iAccessrelationgroup = 0;
	final static public String ACCESSRELATIONGROUP_PROPERTY_ID = "accessrelationgroup";
	final static public Class ACCESSRELATIONGROUP_PROPERTY_CLASS = Integer.class;
	final static public String ACCESSRELATIONGROUP_NAME = "Accessrelationgroup"; // 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

	/** Active */
	public Integer getActive() { return iActive; }
	public void setActive(Integer value)
	{
		try
		{
			Integer lValue = iActive;
			if (log4j.isDebugEnabled()) log4j.debug("setActive: " + lValue + " -> " + value);
			fireVetoableChange(ACTIVE_PROPERTY_ID, lValue, value);
			iActive = value;
			firePropertyChange(ACTIVE_PROPERTY_ID, lValue, value);
		}
		catch (java.beans.PropertyVetoException e) { throw new java.lang.IllegalArgumentException("Value vetoed: " + e.getMessage()); }
	}
	@Column(name="active")
	private Integer iActive = 1;
	final static public String ACTIVE_PROPERTY_ID = "active";
	final static public Class ACTIVE_PROPERTY_CLASS = Integer.class;
	final static public String ACTIVE_NAME = "Active"; // with this ID you can access the internationalization


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

	/** clone */
	public Object clone()
	{ 
		nl.reinders.bm.Contact lNew = new nl.reinders.bm.Contact();
		lNew.setRelation( getRelation() ); 
		lNew.setName( getName() ); 
		lNew.setInformation( getInformation() ); 
		lNew.setPrefix( getPrefix() ); 
		lNew.setWebemail( getWebemail() ); 
		lNew.setWebpassword( getWebpassword() ); 
		lNew.setNewsletter( getNewsletter() ); 
		lNew.setBillpassword( getBillpassword() ); 
		lNew.setAccessrelationgroup( getAccessrelationgroup() ); 
		// not cloning this column: lNew.setDwhmodified( getDwhmodified() ); 
		// not cloning this column: lNew.setDwhby( getDwhby() ); 
		lNew.setActive( getActive() ); 
		return lNew;
	}
	public nl.reinders.bm.Contact cloneShallow() { return (nl.reinders.bm.Contact)clone();}


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

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


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

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

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

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


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

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



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

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


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