/*
 * 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 webdisclaimer.
 * @version    $Revision$
 * @author     $Author$
 */
@MappedSuperclass
abstract public class Webdisclaimer 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(Webdisclaimer.class.getName());

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


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



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

	/** Sessionid */
	public String getSessionid() { return iSessionid; }
	public void setSessionid(String value)
	{
		try
		{
			String lValue = iSessionid;
			if (log4j.isDebugEnabled()) log4j.debug("setSessionid: " + lValue + " -> " + value);
			fireVetoableChange(SESSIONID_PROPERTY_ID, lValue, value);
			iSessionid = value;
			firePropertyChange(SESSIONID_PROPERTY_ID, lValue, value);
		}
		catch (java.beans.PropertyVetoException e) { throw new java.lang.IllegalArgumentException("Value vetoed: " + e.getMessage()); }
	}
	@Id @Column(name="sessionid")
	private String iSessionid = null;
	final static public String SESSIONID_PROPERTY_ID = "sessionid";
	final static public Class SESSIONID_PROPERTY_CLASS = String.class;
	final static public String SESSIONID_NAME = "Sessionid"; // with this ID you can access the internationalization

	/** Companyname */
	public String getCompanyname() { return iCompanyname; }
	public void setCompanyname(String value)
	{
		try
		{
			String lValue = iCompanyname;
			if (log4j.isDebugEnabled()) log4j.debug("setCompanyname: " + lValue + " -> " + value);
			fireVetoableChange(COMPANYNAME_PROPERTY_ID, lValue, value);
			iCompanyname = value;
			firePropertyChange(COMPANYNAME_PROPERTY_ID, lValue, value);
		}
		catch (java.beans.PropertyVetoException e) { throw new java.lang.IllegalArgumentException("Value vetoed: " + e.getMessage()); }
	}
	@Column(name="companyname")
	private String iCompanyname = null;
	final static public String COMPANYNAME_PROPERTY_ID = "companyname";
	final static public Class COMPANYNAME_PROPERTY_CLASS = String.class;
	final static public String COMPANYNAME_NAME = "Companyname"; // with this ID you can access the internationalization

	/** Street */
	public String getStreet() { return iStreet; }
	public void setStreet(String value)
	{
		try
		{
			String lValue = iStreet;
			if (log4j.isDebugEnabled()) log4j.debug("setStreet: " + lValue + " -> " + value);
			fireVetoableChange(STREET_PROPERTY_ID, lValue, value);
			iStreet = value;
			firePropertyChange(STREET_PROPERTY_ID, lValue, value);
		}
		catch (java.beans.PropertyVetoException e) { throw new java.lang.IllegalArgumentException("Value vetoed: " + e.getMessage()); }
	}
	@Column(name="street")
	private String iStreet = null;
	final static public String STREET_PROPERTY_ID = "street";
	final static public Class STREET_PROPERTY_CLASS = String.class;
	final static public String STREET_NAME = "Street"; // with this ID you can access the internationalization

	/** City */
	public String getCity() { return iCity; }
	public void setCity(String value)
	{
		try
		{
			String lValue = iCity;
			if (log4j.isDebugEnabled()) log4j.debug("setCity: " + lValue + " -> " + value);
			fireVetoableChange(CITY_PROPERTY_ID, lValue, value);
			iCity = value;
			firePropertyChange(CITY_PROPERTY_ID, lValue, value);
		}
		catch (java.beans.PropertyVetoException e) { throw new java.lang.IllegalArgumentException("Value vetoed: " + e.getMessage()); }
	}
	@Column(name="city")
	private String iCity = null;
	final static public String CITY_PROPERTY_ID = "city";
	final static public Class CITY_PROPERTY_CLASS = String.class;
	final static public String CITY_NAME = "City"; // with this ID you can access the internationalization

	/** Country */
	public String getCountry() { return iCountry; }
	public void setCountry(String value)
	{
		try
		{
			String lValue = iCountry;
			if (log4j.isDebugEnabled()) log4j.debug("setCountry: " + lValue + " -> " + value);
			fireVetoableChange(COUNTRY_PROPERTY_ID, lValue, value);
			iCountry = value;
			firePropertyChange(COUNTRY_PROPERTY_ID, lValue, value);
		}
		catch (java.beans.PropertyVetoException e) { throw new java.lang.IllegalArgumentException("Value vetoed: " + e.getMessage()); }
	}
	@Column(name="country")
	private String iCountry = null;
	final static public String COUNTRY_PROPERTY_ID = "country";
	final static public Class COUNTRY_PROPERTY_CLASS = String.class;
	final static public String COUNTRY_NAME = "Country"; // with this ID you can access the internationalization

	/** Fullname */
	public String getFullname() { return iFullname; }
	public void setFullname(String value)
	{
		try
		{
			String lValue = iFullname;
			if (log4j.isDebugEnabled()) log4j.debug("setFullname: " + lValue + " -> " + value);
			fireVetoableChange(FULLNAME_PROPERTY_ID, lValue, value);
			iFullname = value;
			firePropertyChange(FULLNAME_PROPERTY_ID, lValue, value);
		}
		catch (java.beans.PropertyVetoException e) { throw new java.lang.IllegalArgumentException("Value vetoed: " + e.getMessage()); }
	}
	@Column(name="fullname")
	private String iFullname = null;
	final static public String FULLNAME_PROPERTY_ID = "fullname";
	final static public Class FULLNAME_PROPERTY_CLASS = String.class;
	final static public String FULLNAME_NAME = "Fullname"; // with this ID you can access the internationalization

	/** Email */
	public String getEmail() { return iEmail; }
	public void setEmail(String value)
	{
		try
		{
			String lValue = iEmail;
			if (log4j.isDebugEnabled()) log4j.debug("setEmail: " + lValue + " -> " + value);
			fireVetoableChange(EMAIL_PROPERTY_ID, lValue, value);
			iEmail = value;
			firePropertyChange(EMAIL_PROPERTY_ID, lValue, value);
		}
		catch (java.beans.PropertyVetoException e) { throw new java.lang.IllegalArgumentException("Value vetoed: " + e.getMessage()); }
	}
	@Column(name="email")
	private String iEmail = null;
	final static public String EMAIL_PROPERTY_ID = "email";
	final static public Class EMAIL_PROPERTY_CLASS = String.class;
	final static public String EMAIL_NAME = "Email"; // with this ID you can access the internationalization

	/** Licenseacceptancedate */
	public java.util.Calendar getLicenseacceptancedate() { return iLicenseacceptancedate; }
	public void setLicenseacceptancedate(java.util.Calendar value)
	{
		try
		{
			java.util.Calendar lValue = iLicenseacceptancedate;
			if (log4j.isDebugEnabled()) log4j.debug("setLicenseacceptancedate: " + lValue + " -> " + value);
			fireVetoableChange(LICENSEACCEPTANCEDATE_PROPERTY_ID, lValue, value);
			iLicenseacceptancedate = value;
			firePropertyChange(LICENSEACCEPTANCEDATE_PROPERTY_ID, lValue, value);
		}
		catch (java.beans.PropertyVetoException e) { throw new java.lang.IllegalArgumentException("Value vetoed: " + e.getMessage()); }
	}
	@Id @Temporal(TemporalType.TIMESTAMP) @Column(name="licenseacceptancedate")
	private java.util.Calendar iLicenseacceptancedate = new java.util.GregorianCalendar();
	final static public String LICENSEACCEPTANCEDATE_PROPERTY_ID = "licenseacceptancedate";
	final static public Class LICENSEACCEPTANCEDATE_PROPERTY_CLASS = java.util.Calendar.class;
	final static public String LICENSEACCEPTANCEDATE_NAME = "Licenseacceptancedate"; // with this ID you can access the internationalization

	/** Licensetext */
	public String getLicensetext() { return iLicensetext; }
	public void setLicensetext(String value)
	{
		try
		{
			String lValue = iLicensetext;
			if (log4j.isDebugEnabled()) log4j.debug("setLicensetext: " + lValue + " -> " + value);
			fireVetoableChange(LICENSETEXT_PROPERTY_ID, lValue, value);
			iLicensetext = value;
			firePropertyChange(LICENSETEXT_PROPERTY_ID, lValue, value);
		}
		catch (java.beans.PropertyVetoException e) { throw new java.lang.IllegalArgumentException("Value vetoed: " + e.getMessage()); }
	}
	@Column(name="licensetext")
	private String iLicensetext = null;
	final static public String LICENSETEXT_PROPERTY_ID = "licensetext";
	final static public Class LICENSETEXT_PROPERTY_CLASS = String.class;
	final static public String LICENSETEXT_NAME = "Licensetext"; // with this ID you can access the internationalization


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

	/** clone */
	public Object clone()
	{ 
		nl.reinders.bm.Webdisclaimer lNew = new nl.reinders.bm.Webdisclaimer();
		lNew.setCompanyname( getCompanyname() ); 
		lNew.setStreet( getStreet() ); 
		lNew.setCity( getCity() ); 
		lNew.setCountry( getCountry() ); 
		lNew.setFullname( getFullname() ); 
		lNew.setEmail( getEmail() ); 
		lNew.setLicensetext( getLicensetext() ); 
		return lNew;
	}
	public nl.reinders.bm.Webdisclaimer cloneShallow() { return (nl.reinders.bm.Webdisclaimer)clone();}


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

	/**
	 * @param licenseacceptancedate
	 * @param sessionid
	 */
	static public nl.reinders.bm.Webdisclaimer findByPK(java.util.Calendar licenseacceptancedate, String sessionid)
	{
		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 Webdisclaimer t where t.iLicenseacceptancedate=:licenseacceptancedate and t.iSessionid=:sessionid");
		lQuery.setParameter("licenseacceptancedate", licenseacceptancedate);
		lQuery.setParameter("sessionid", sessionid);
		java.util.List<nl.reinders.bm.Webdisclaimer> lList = lQuery.getResultList();
	    if (lList.size() == 0) return null;
	    return lList.get(0);
	}

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

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


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

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



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

	/**
	 *
	 */
	public String toString()
	{
		StringBuffer lStringBuffer = new StringBuffer();
		lStringBuffer.append(super.toString());
		lStringBuffer.append(", Sessionid="); lStringBuffer.append(getSessionid());
		lStringBuffer.append(", Licenseacceptancedate="); lStringBuffer.append(getLicenseacceptancedate());
		return lStringBuffer.toString();
	}


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