correção toString enums
parent
03bf64d5be
commit
7438fb4737
|
@ -7,6 +7,7 @@ import java.sql.SQLException;
|
|||
import java.sql.Types;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.usertype.ParameterizedType;
|
||||
import org.hibernate.usertype.UserType;
|
||||
|
@ -60,11 +61,15 @@ public class CustomEnumTypeHibernate implements UserType, ParameterizedType {
|
|||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("rawtypes")
|
||||
public void nullSafeSet(PreparedStatement st, Object value, int index) throws HibernateException, SQLException {
|
||||
if (value == null) {
|
||||
st.setNull(index, Types.VARCHAR);
|
||||
int sqlType = Integer.valueOf(parameters.get("sqlType").toString()) ;
|
||||
boolean enumName = Boolean.valueOf(parameters.get("enumName").toString()) ;
|
||||
if (value == null || StringUtils.isEmpty(value.toString())) {
|
||||
st.setNull(index, sqlType);
|
||||
} else {
|
||||
st.setObject(index, value.toString(), Types.VARCHAR);
|
||||
Enum enumerator = (Enum) value;
|
||||
st.setObject(index, enumName ? enumerator.name() : enumerator.ordinal(), sqlType);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,104 +1,40 @@
|
|||
package com.rjconsultores.ventaboletos.constantes;
|
||||
|
||||
public enum TipoEventoExtra {
|
||||
NAO_ESPECIFICADO{
|
||||
public String toString() {
|
||||
return " ";
|
||||
}
|
||||
},
|
||||
OUTRO{
|
||||
public String toString() {
|
||||
return "OUTRO";
|
||||
}
|
||||
},
|
||||
SEGURO_OPCIONAL{
|
||||
public String toString() {
|
||||
return "SEGURO_OPCIONAL";
|
||||
}
|
||||
},
|
||||
EXCESSO_BAGAGEM{
|
||||
public String toString() {
|
||||
return "EXCESSO_BAGAGEM";
|
||||
}
|
||||
},
|
||||
TAXA_EMBARQUE{
|
||||
public String toString() {
|
||||
return "TAXA_EMBARQUE";
|
||||
}
|
||||
},
|
||||
SEGURO_RESSARCIMENTO{
|
||||
public String toString() {
|
||||
return "SEGURO_RESSARCIMENTO";
|
||||
}
|
||||
},
|
||||
TAXA_EMBARQUE_RESSARCIMENTO{
|
||||
public String toString() {
|
||||
return "TAXA_EMBARQUE_RESSARCIMENTO";
|
||||
}
|
||||
},
|
||||
MULTA{
|
||||
public String toString() {
|
||||
return "MULTA";
|
||||
}
|
||||
},
|
||||
DIF_MAIOR{
|
||||
public String toString() {
|
||||
return "DIF_MAIOR";
|
||||
}
|
||||
},
|
||||
DIF_MENOR{
|
||||
public String toString() {
|
||||
return "DIF_MENOR";
|
||||
}
|
||||
},
|
||||
SUPRIMENTO{
|
||||
public String toString() {
|
||||
return "SUPRIMENTO";
|
||||
}
|
||||
},
|
||||
SANGRIA{
|
||||
public String toString() {
|
||||
return "SANGRIA";
|
||||
}
|
||||
},
|
||||
RECARGA_CELULAR{
|
||||
public String toString() {
|
||||
return "RECARGA_CELULAR";
|
||||
}
|
||||
},
|
||||
RECARGA_TV{
|
||||
public String toString() {
|
||||
return "RECARGA_TV";
|
||||
}
|
||||
},
|
||||
RECARGA_PIN{
|
||||
public String toString() {
|
||||
return "RECARGA_PIN";
|
||||
}
|
||||
},
|
||||
PACOTE{
|
||||
public String toString() {
|
||||
return "PACOTE";
|
||||
}
|
||||
},
|
||||
SMART_CARD{
|
||||
public String toString() {
|
||||
return "SMART_CARD";
|
||||
}
|
||||
},
|
||||
TAXA_CONVENIENCIA_SVI{
|
||||
public String toString() {
|
||||
return "TAXA_CONVENIENCIA_SVI";
|
||||
}
|
||||
},
|
||||
TARIFA_SAFER{
|
||||
public String toString() {
|
||||
return "TARIFA_SAFER";
|
||||
}
|
||||
},
|
||||
JUROS_CARTAO_CREDITO{
|
||||
public String toString() {
|
||||
return "JUROS_CARTAO_CREDITO";
|
||||
}
|
||||
};
|
||||
|
||||
OUTRO("OUTRO"),
|
||||
SEGURO_OPCIONAL("SEGURO_OPCIONAL"),
|
||||
EXCESSO_BAGAGEM("EXCESSO_BAGAGEM"),
|
||||
TAXA_EMBARQUE("TAXA_EMBARQUE"),
|
||||
SEGURO_RESSARCIMENTO("SEGURO_RESSARCIMENTO"),
|
||||
TAXA_EMBARQUE_RESSARCIMENTO("TAXA_EMBARQUE_RESSARCIMENTO"),
|
||||
MULTA("MULTA"),
|
||||
DIF_MAIOR("DIF_MAIOR"),
|
||||
DIF_MENOR("DIF_MENOR"),
|
||||
SUPRIMENTO("SUPRIMENTO"),
|
||||
SANGRIA("SANGRIA"),
|
||||
RECARGA_CELULAR("RECARGA_CELULAR"),
|
||||
RECARGA_TV("RECARGA_TV"),
|
||||
RECARGA_PIN("RECARGA_PIN"),
|
||||
PACOTE("PACOTE"),
|
||||
SMART_CARD("SMART_CARD"),
|
||||
TAXA_CONVENIENCIA_SVI("TAXA_CONVENIENCIA_SVI"),
|
||||
TARIFA_SAFER("TARIFA_SAFER"),
|
||||
JUROS_CARTAO_CREDITO("JUROS_CARTAO_CREDITO"),
|
||||
;
|
||||
|
||||
private String descricao;
|
||||
|
||||
private TipoEventoExtra(String descricao) {
|
||||
this.descricao = descricao;
|
||||
}
|
||||
|
||||
public String getDescricao() {
|
||||
return descricao;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getDescricao();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,8 +25,6 @@ import javax.persistence.Temporal;
|
|||
import javax.persistence.TemporalType;
|
||||
import javax.persistence.Transient;
|
||||
|
||||
import org.apache.commons.lang.BooleanUtils;
|
||||
|
||||
import org.hibernate.annotations.Parameter;
|
||||
import org.hibernate.annotations.Type;
|
||||
|
||||
|
@ -104,13 +102,17 @@ public class Categoria implements Serializable, Auditavel<Categoria>{
|
|||
|
||||
@Type(type = "com.rjconsultores.ventaboletos.constantes.CustomEnumTypeHibernate", parameters = {
|
||||
@Parameter(name = "type", value = "com.rjconsultores.ventaboletos.constantes.CustomEnumTypeHibernate"),
|
||||
@Parameter(name = "class", value = "com.rjconsultores.ventaboletos.enums.TipoDescontoMonitrip.class"), })
|
||||
@Parameter(name = "class", value = "com.rjconsultores.ventaboletos.enums.TipoDescontoMonitrip"),
|
||||
@Parameter(name = "sqlType", value = "12")/*Types.VARCHAR*/,
|
||||
@Parameter(name = "enumName", value = "true")})
|
||||
@Column(name = "desconto_monitrip")
|
||||
private com.rjconsultores.ventaboletos.enums.TipoDescontoMonitrip tipoDescontoMonitrip;
|
||||
|
||||
@Type(type = "com.rjconsultores.ventaboletos.constantes.CustomEnumTypeHibernate", parameters = {
|
||||
@Parameter(name = "type", value = "com.rjconsultores.ventaboletos.constantes.CustomEnumTypeHibernate"),
|
||||
@Parameter(name = "class", value = "com.rjconsultores.ventaboletos.enums.TipoDescontoBPe.class"), })
|
||||
@Parameter(name = "class", value = "com.rjconsultores.ventaboletos.enums.TipoDescontoBPe"),
|
||||
@Parameter(name = "sqlType", value = "12")/*Types.VARCHAR*/,
|
||||
@Parameter(name = "enumName", value = "true")})
|
||||
@Column(name = "DESCONTOBPE")
|
||||
private com.rjconsultores.ventaboletos.enums.TipoDescontoBPe tipoDescontoBPe;
|
||||
|
||||
|
|
|
@ -86,7 +86,9 @@ public class ClaseServicio implements Serializable, Auditavel<ClaseServicio> {
|
|||
|
||||
@Type(type = "com.rjconsultores.ventaboletos.constantes.CustomEnumTypeHibernate", parameters = {
|
||||
@Parameter(name = "type", value = "com.rjconsultores.ventaboletos.constantes.CustomEnumTypeHibernate"),
|
||||
@Parameter(name = "class", value = "com.rjconsultores.ventaboletos.enums.TipoClasseServicoBPe.class"), })
|
||||
@Parameter(name = "class", value = "com.rjconsultores.ventaboletos.enums.TipoClasseServicoBPe"),
|
||||
@Parameter(name = "sqlType", value = "12")/*Types.VARCHAR*/,
|
||||
@Parameter(name = "enumName", value = "true")})
|
||||
@Column(name = "desconto_monitrip")
|
||||
private com.rjconsultores.ventaboletos.enums.TipoClasseServicoBPe tipoDescontoMonitrip;
|
||||
|
||||
|
|
|
@ -66,7 +66,9 @@ public class EstacionSitef implements Serializable {
|
|||
|
||||
@Type(type = "com.rjconsultores.ventaboletos.constantes.CustomEnumTypeHibernate", parameters = {
|
||||
@Parameter(name = "type", value = "com.rjconsultores.ventaboletos.constantes.CustomEnumTypeHibernate"),
|
||||
@Parameter(name = "class", value = "com.rjconsultores.ventaboletos.enums.TipoIntegracaoTEF.class"), })
|
||||
@Parameter(name = "class", value = "com.rjconsultores.ventaboletos.enums.TipoIntegracaoTEF"),
|
||||
@Parameter(name = "sqlType", value = "12")/*Types.VARCHAR*/,
|
||||
@Parameter(name = "enumName", value = "true")})
|
||||
@Column(name = "TIPO_INTEGRACAO")
|
||||
private com.rjconsultores.ventaboletos.enums.TipoIntegracaoTEF tipoIntegracao;
|
||||
|
||||
|
|
|
@ -80,7 +80,9 @@ public class FormaPago implements Serializable, Auditavel<FormaPago> {
|
|||
|
||||
@Type(type = "com.rjconsultores.ventaboletos.constantes.CustomEnumTypeHibernate", parameters = {
|
||||
@Parameter(name = "type", value = "com.rjconsultores.ventaboletos.constantes.CustomEnumTypeHibernate"),
|
||||
@Parameter(name = "class", value = "com.rjconsultores.ventaboletos.enums.TipoFormapago.class"), })
|
||||
@Parameter(name = "class", value = "com.rjconsultores.ventaboletos.enums.TipoFormapago"),
|
||||
@Parameter(name = "sqlType", value = "4")/*Types.INTEGER*/,
|
||||
@Parameter(name = "enumName", value = "false")})
|
||||
@Column(name = "TIPO_PAGO")
|
||||
private com.rjconsultores.ventaboletos.enums.TipoFormapago tipoFormapago;
|
||||
@Column(name = "CVESISTEMA")
|
||||
|
@ -98,7 +100,9 @@ public class FormaPago implements Serializable, Auditavel<FormaPago> {
|
|||
|
||||
@Type(type = "com.rjconsultores.ventaboletos.constantes.CustomEnumTypeHibernate", parameters = {
|
||||
@Parameter(name = "type", value = "com.rjconsultores.ventaboletos.constantes.CustomEnumTypeHibernate"),
|
||||
@Parameter(name = "class", value = "com.rjconsultores.ventaboletos.enums.TipoCarteiraDigital.class"), })
|
||||
@Parameter(name = "class", value = "com.rjconsultores.ventaboletos.enums.TipoCarteiraDigital"),
|
||||
@Parameter(name = "sqlType", value = "12")/*Types.VARCHAR*/,
|
||||
@Parameter(name = "enumName", value = "true")})
|
||||
@Column(name = "TIPO_CARTEIRA_DIGITAL")
|
||||
private com.rjconsultores.ventaboletos.enums.TipoCarteiraDigital tipoCarteiraDigital;
|
||||
|
||||
|
|
|
@ -105,7 +105,9 @@ public class TipoEventoExtra implements Serializable {
|
|||
|
||||
@Type(type = "com.rjconsultores.ventaboletos.constantes.CustomEnumTypeHibernate", parameters = {
|
||||
@Parameter(name = "type", value = "com.rjconsultores.ventaboletos.constantes.CustomEnumTypeHibernate"),
|
||||
@Parameter(name = "class", value = "com.rjconsultores.ventaboletos.constantes.TipoEventoExtra"), })
|
||||
@Parameter(name = "class", value = "com.rjconsultores.ventaboletos.constantes.TipoEventoExtra"),
|
||||
@Parameter(name = "sqlType", value = "12")/*Types.VARCHAR*/,
|
||||
@Parameter(name = "enumName", value = "true")})
|
||||
@Column(name = "CVETIPOEVENTO")
|
||||
private com.rjconsultores.ventaboletos.constantes.TipoEventoExtra cvetipoevento;
|
||||
|
||||
|
|
Loading…
Reference in New Issue