maia/.svn/pristine/75/7521262afdee20aa67bad1f57d1...

216 lines
5.8 KiB
Plaintext
Executable File
Raw Permalink Blame History

package com.fp.persistence.pgeneral.safe;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import java.sql.Timestamp;
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;
/**Clase que implementa la entidad de Hibernate que hace referencia a la tabla TSAFEUSERSESSION*/
@Entity(name="TsafeUserSession")
@Table(name="TSAFEUSERSESSION")
public class TsafeUserSession 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 TsafeUserSession
*/
@EmbeddedId
private TsafeUserSessionKey pk;
@Column(name="DATEFROM", nullable=true)
/**
* Fecha desde la cual esta vigente el registro.
*/
private Timestamp datefrom;
@Column(name="TERMINALCODE", nullable=true)
/**
* Codigo de terminal desde el cual se conecta el usuario.
*/
private String terminalcode;
@Column(name="TRYNUMBER", nullable=true)
/**
* Numero de intentos de coneccion.
*/
private Integer trynumber;
@Column(name="SESSIONID", nullable=true)
/**
* Session id del browser con el servlet.
*/
private String sessionid;
@Column(name="WEBSERVERIP", nullable=true)
/**
* Ip del servidor de aplicaciones al cual esta conectado un usuario, sirve para caducar las sessiones de usuario asociadas a esta ip
*/
private String webserverip;
/**Contructor por defecto*/
public TsafeUserSession(){
}
/**Contructor de TsafeUserSession
@param pPk Clave Primaria del entity
*/
public TsafeUserSession(TsafeUserSessionKey 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 TsafeUserSession
*/
public static TsafeUserSession find(EntityManager pEntityManager,TsafeUserSessionKey pKey) throws Exception{
TsafeUserSession obj = pEntityManager.find(TsafeUserSession.class,pKey);
return obj;
}
/**Entrega la Clave primaria de TsafeUserSession
@return El objeto que referencia a la Clave primaria de TsafeUserSession
*/
public TsafeUserSessionKey getPk(){
return pk;
}
/**Fija un nuevo valor a la Clave primaria de TsafeUserSession
@param pPk El objeto que referencia a la nueva Clave primaria de TsafeUserSession
*/
public void setPk(TsafeUserSessionKey pPk){
pk=pPk;
}
/**Obtiene el valor de datefrom
@return valor de datefrom*/
public Timestamp getDatefrom(){
return datefrom;
}
/**Fija el valor de datefrom
@param pDatefrom nuevo Valor de datefrom*/
public void setDatefrom(Timestamp pDatefrom){
datefrom=pDatefrom;
}
/**Obtiene el valor de terminalcode
@return valor de terminalcode*/
public String getTerminalcode(){
return terminalcode;
}
/**Fija el valor de terminalcode
@param pTerminalcode nuevo Valor de terminalcode*/
public void setTerminalcode(String pTerminalcode){
terminalcode=pTerminalcode;
}
/**Obtiene el valor de trynumber
@return valor de trynumber*/
public Integer getTrynumber(){
return trynumber;
}
/**Fija el valor de trynumber
@param pTrynumber nuevo Valor de trynumber*/
public void setTrynumber(Integer pTrynumber){
trynumber=pTrynumber;
}
/**Obtiene el valor de sessionid
@return valor de sessionid*/
public String getSessionid(){
return sessionid;
}
/**Fija el valor de sessionid
@param pSessionid nuevo Valor de sessionid*/
public void setSessionid(String pSessionid){
sessionid=pSessionid;
}
/**Obtiene el valor de webserverip
@return valor de webserverip*/
public String getWebserverip(){
return webserverip;
}
/**Fija el valor de webserverip
@param pWebserverip nuevo Valor de webserverip*/
public void setWebserverip(String pWebserverip){
webserverip=pWebserverip;
}
public boolean equals(Object rhs){
if (rhs == null)return false;
if (! (rhs instanceof TsafeUserSession))return false;
TsafeUserSession that = (TsafeUserSession) rhs;
if (this.getPk() == null || that.getPk() == null)
return false;
return (this.getPk().equals(that.getPk()));
}
/**Implementaci<63>n del metodo hashCode de la la entidad TsafeUserSession
@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<63>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<63>n de la creaci<63>n de un bean en blanco TsafeUserSession
*/
public Object createInstance(){
TsafeUserSession instance=new TsafeUserSession();
instance.setPk(new TsafeUserSessionKey());
return instance;
}
/**Clona la entidad TsafeUserSession
@see com.fp.dto.hb.HibernateBean#cloneMe()
*/
public Object cloneMe() throws CloneNotSupportedException{
TsafeUserSession p=(TsafeUserSession)this.clone();
p.setPk((TsafeUserSessionKey)this.pk.cloneMe());
return p;
}
public Object getId() {
return this.pk;
}
}