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

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


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



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

	/** Src */
	public String getSrc() { return iSrc; }
	public void setSrc(String value)
	{
		try
		{
			String lValue = iSrc;
			if (log4j.isDebugEnabled()) log4j.debug("setSrc: " + lValue + " -> " + value);
			fireVetoableChange(SRC_PROPERTY_ID, lValue, value);
			iSrc = value;
			firePropertyChange(SRC_PROPERTY_ID, lValue, value);
		}
		catch (java.beans.PropertyVetoException e) { throw new java.lang.IllegalArgumentException("Value vetoed: " + e.getMessage()); }
	}
	@Id @Column(name="src")
	private String iSrc = null;
	final static public String SRC_PROPERTY_ID = "src";
	final static public Class SRC_PROPERTY_CLASS = String.class;
	final static public String SRC_NAME = "Src"; // with this ID you can access the internationalization

	/** Scope */
	public String getScope() { return iScope; }
	public void setScope(String value)
	{
		try
		{
			String lValue = iScope;
			if (log4j.isDebugEnabled()) log4j.debug("setScope: " + lValue + " -> " + value);
			fireVetoableChange(SCOPE_PROPERTY_ID, lValue, value);
			iScope = value;
			firePropertyChange(SCOPE_PROPERTY_ID, lValue, value);
		}
		catch (java.beans.PropertyVetoException e) { throw new java.lang.IllegalArgumentException("Value vetoed: " + e.getMessage()); }
	}
	@Id @Column(name="scope")
	private String iScope = null;
	final static public String SCOPE_PROPERTY_ID = "scope";
	final static public Class SCOPE_PROPERTY_CLASS = String.class;
	final static public String SCOPE_NAME = "Scope"; // with this ID you can access the internationalization

	/** Dst */
	public String getDst() { return iDst; }
	public void setDst(String value)
	{
		try
		{
			String lValue = iDst;
			if (log4j.isDebugEnabled()) log4j.debug("setDst: " + lValue + " -> " + value);
			fireVetoableChange(DST_PROPERTY_ID, lValue, value);
			iDst = value;
			firePropertyChange(DST_PROPERTY_ID, lValue, value);
		}
		catch (java.beans.PropertyVetoException e) { throw new java.lang.IllegalArgumentException("Value vetoed: " + e.getMessage()); }
	}
	@Column(name="dst")
	private String iDst = null;
	final static public String DST_PROPERTY_ID = "dst";
	final static public Class DST_PROPERTY_CLASS = String.class;
	final static public String DST_NAME = "Dst"; // 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


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

	/** clone */
	public Object clone()
	{ 
		nl.reinders.bm.OvsInternational lNew = new nl.reinders.bm.OvsInternational();
		lNew.setDst( getDst() ); 
		return lNew;
	}
	public nl.reinders.bm.OvsInternational cloneShallow() { return (nl.reinders.bm.OvsInternational)clone();}


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

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

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

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


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

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



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

	/**
	 *
	 */
	public String toString()
	{
		StringBuffer lStringBuffer = new StringBuffer();
		lStringBuffer.append(super.toString());
		lStringBuffer.append(", Src="); lStringBuffer.append(getSrc());
		lStringBuffer.append(", Scope="); lStringBuffer.append(getScope());
		return lStringBuffer.toString();
	}


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