package com.fp.persistence.pgeneral.date; import javax.persistence.EmbeddedId; import javax.persistence.Entity; import javax.persistence.Column; import javax.persistence.EntityManager; import java.io.Serializable; import javax.persistence.Table; import com.fp.dto.hb.HibernateBean; import java.lang.reflect.Field; import javax.persistence.Transient; import java.sql.Date; /**Clase que implementa la entidad de Hibernate que hace referencia a la tabla TGENEACCOUNTINGDATE*/ @Entity(name="TgeneAccountingDate") @Table(name="TGENEACCOUNTINGDATE") public class TgeneAccountingDate extends com.fp.dto.AbstractDataTransport implements Serializable,HibernateBean,Cloneable{ /** * HashCode asociado con la Instancia */ @Transient private int hashValue = 0; /** * Version de la Clase */ private static final long serialVersionUID = 1L; /** * Clave primaria de la Entidad TgeneAccountingDate */ @EmbeddedId private TgeneAccountingDateKey pk; @Column(name="ACCOUNTINGDATE", nullable=true) /** * Fecha contable. */ private Date accountingdate; @Column(name="WORKINGDATE", nullable=true) /** * Fecha de proceso o de trabajo */ private Date workingdate; /**Contructor por defecto*/ public TgeneAccountingDate(){ } /**Contructor de TgeneAccountingDate @param pPk Clave Primaria del entity */ public TgeneAccountingDate(TgeneAccountingDateKey pPk){ this(); pk=pPk; } /** * Metodo que entrega datos de la tabla dada la clave primaria. * @param pEntityManager referencia de la session a obtener datos del bean. * @param pKey Caleve primaria del bean. * @return TgeneAccountingDate */ public static TgeneAccountingDate find(EntityManager pEntityManager,TgeneAccountingDateKey pKey) throws Exception{ TgeneAccountingDate obj = pEntityManager.find(TgeneAccountingDate.class,pKey); return obj; } /**Entrega la Clave primaria de TgeneAccountingDate @return El objeto que referencia a la Clave primaria de TgeneAccountingDate */ public TgeneAccountingDateKey getPk(){ return pk; } /**Fija un nuevo valor a la Clave primaria de TgeneAccountingDate @param pPk El objeto que referencia a la nueva Clave primaria de TgeneAccountingDate */ public void setPk(TgeneAccountingDateKey pPk){ pk=pPk; } /**Obtiene el valor de accountingdate @return valor de accountingdate*/ public Date getAccountingdate(){ return accountingdate; } /**Fija el valor de accountingdate @param pAccountingdate nuevo Valor de accountingdate*/ public void setAccountingdate(Date pAccountingdate){ accountingdate=pAccountingdate; } /**Obtiene el valor de workingdate @return valor de workingdate*/ public Date getWorkingdate(){ return workingdate; } /**Fija el valor de workingdate @param pWorkingdate nuevo Valor de workingdate*/ public void setWorkingdate(Date pWorkingdate){ workingdate=pWorkingdate; } public boolean equals(Object rhs){ if (rhs == null)return false; if (! (rhs instanceof TgeneAccountingDate))return false; TgeneAccountingDate that = (TgeneAccountingDate) rhs; if (this.getPk() == null || that.getPk() == null) return false; return (this.getPk().equals(that.getPk())); } /**Implementación del metodo hashCode de la la entidad TgeneAccountingDate @return el hashCode la instancia */ public int hashCode() { if (this.hashValue == 0){ int result = 17; if (this.getPk() == null){ result = super.hashCode(); }else{ result = this.getPk().hashCode(); } this.hashValue = result; } return this.hashValue; } /**Implementación toString */ public String toString() { Field[]fs=this.getClass().getDeclaredFields(); String data=""; for(Field f:fs){ try{ String name=f.getName(); if(f.getType().getName().compareTo("java.util.Set")==0)continue; if(name.compareTo("hashValue")==0||name.compareTo("serialVersionUID")==0)continue; data+=name+"="+f.get(this)+";"; }catch(Exception e){ continue; } } if(data.compareTo("")==0){ data=super.toString(); } return data; } /**Implementación de la creación de un bean en blanco TgeneAccountingDate */ public Object createInstance(){ TgeneAccountingDate instance=new TgeneAccountingDate(); instance.setPk(new TgeneAccountingDateKey()); return instance; } /**Clona la entidad TgeneAccountingDate @see com.fp.dto.hb.HibernateBean#cloneMe() */ public Object cloneMe() throws CloneNotSupportedException{ TgeneAccountingDate p=(TgeneAccountingDate)this.clone(); p.setPk((TgeneAccountingDateKey)this.pk.cloneMe()); return p; } }