Boa Tarde Galera!
Estou fazendo um select que usa uma classe DTO para me retornar os dados e esta retornando erro expected type: java.util.Calendar, actual value: java.sql.Timestamp estou tentando converter ou colocar ou tipo de dado e nada funciona
Porfavor me deem uma :idea: …
Código DTO
import java.io.Serializable;
import java.util.Calendar;
public class TransporteEscolarDTO implements Serializable {
private static final long serialVersionUID = 7097211954406083621L;
private String id;
private String idPessoa;
private String pessoa;
private Calendar dtRegistro;
private String noEscola;
private Integer escola;
private String anoLetivo;
private Calendar dtExclusao;
private String idUsuarioInseriu;
private String usuarioInseriu;
private String idUsuarioExcluiu;
private String usuarioExcluiu;
private String obs;
private String idMatricula;
private String tipoEnsino;
private String serie;
private String situacao;
private String turma;
private String turno;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getIdPessoa() {
return idPessoa;
}
public void setIdPessoa(String idPessoa) {
this.idPessoa = idPessoa;
}
public String getPessoa() {
return pessoa;
}
public void setPessoa(String pessoa) {
this.pessoa = pessoa;
}
public Calendar getDtRegistro() {
return dtRegistro;
}
public void setDtRegistro(Calendar dtRegistro) {
this.dtRegistro = dtRegistro;
}
public String getNoEscola() {
return noEscola;
}
public void setNoEscola(String noEscola) {
this.noEscola = noEscola;
}
public Integer getEscola() {
return escola;
}
public void setEscola(Integer escola) {
this.escola = escola;
}
public String getAnoLetivo() {
return anoLetivo;
}
public void setAnoLetivo(String anoLetivo) {
this.anoLetivo = anoLetivo;
}
public Calendar getDtExclusao() {
return dtExclusao;
}
public void setDtExclusao(Calendar dtExclusao) {
this.dtExclusao = dtExclusao;
}
public String getIdUsuarioInseriu() {
return idUsuarioInseriu;
}
public void setIdUsuarioInseriu(String idUsuarioInseriu) {
this.idUsuarioInseriu = idUsuarioInseriu;
}
public String getUsuarioInseriu() {
return usuarioInseriu;
}
public void setUsuarioInseriu(String usuarioInseriu) {
this.usuarioInseriu = usuarioInseriu;
}
public String getIdUsuarioExcluiu() {
return idUsuarioExcluiu;
}
public void setIdUsuarioExcluiu(String idUsuarioExcluiu) {
this.idUsuarioExcluiu = idUsuarioExcluiu;
}
public String getUsuarioExcluiu() {
return usuarioExcluiu;
}
public void setUsuarioExcluiu(String usuarioExcluiu) {
this.usuarioExcluiu = usuarioExcluiu;
}
public String getObs() {
return obs;
}
public void setObs(String obs) {
this.obs = obs;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result
+ ((anoLetivo == null) ? 0 : anoLetivo.hashCode());
result = prime * result + ((escola == null) ? 0 : escola.hashCode());
result = prime * result + ((id == null) ? 0 : id.hashCode());
result = prime * result
+ ((idPessoa == null) ? 0 : idPessoa.hashCode());
result = prime
* result
+ ((idUsuarioExcluiu == null) ? 0 : idUsuarioExcluiu.hashCode());
result = prime
* result
+ ((idUsuarioInseriu == null) ? 0 : idUsuarioInseriu.hashCode());
result = prime * result
+ ((noEscola == null) ? 0 : noEscola.hashCode());
result = prime * result + ((obs == null) ? 0 : obs.hashCode());
result = prime * result + ((pessoa == null) ? 0 : pessoa.hashCode());
result = prime * result
+ ((usuarioExcluiu == null) ? 0 : usuarioExcluiu.hashCode());
result = prime * result
+ ((usuarioInseriu == null) ? 0 : usuarioInseriu.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
TransporteEscolarDTO other = (TransporteEscolarDTO) obj;
if (anoLetivo == null) {
if (other.anoLetivo != null)
return false;
} else if (!anoLetivo.equals(other.anoLetivo))
return false;
if (escola == null) {
if (other.escola != null)
return false;
} else if (!escola.equals(other.escola))
return false;
if (id == null) {
if (other.id != null)
return false;
} else if (!id.equals(other.id))
return false;
if (idPessoa == null) {
if (other.idPessoa != null)
return false;
} else if (!idPessoa.equals(other.idPessoa))
return false;
if (idUsuarioExcluiu == null) {
if (other.idUsuarioExcluiu != null)
return false;
} else if (!idUsuarioExcluiu.equals(other.idUsuarioExcluiu))
return false;
if (idUsuarioInseriu == null) {
if (other.idUsuarioInseriu != null)
return false;
} else if (!idUsuarioInseriu.equals(other.idUsuarioInseriu))
return false;
if (noEscola == null) {
if (other.noEscola != null)
return false;
} else if (!noEscola.equals(other.noEscola))
return false;
if (obs == null) {
if (other.obs != null)
return false;
} else if (!obs.equals(other.obs))
return false;
if (pessoa == null) {
if (other.pessoa != null)
return false;
} else if (!pessoa.equals(other.pessoa))
return false;
if (usuarioExcluiu == null) {
if (other.usuarioExcluiu != null)
return false;
} else if (!usuarioExcluiu.equals(other.usuarioExcluiu))
return false;
if (usuarioInseriu == null) {
if (other.usuarioInseriu != null)
return false;
} else if (!usuarioInseriu.equals(other.usuarioInseriu))
return false;
return true;
}
@Override
public String toString() {
return "TransporteEscolarDTO [id=" + id + ", idPessoa=" + idPessoa
+ ", pessoa=" + pessoa
+ ", noEscola=" + noEscola + ", escola=" + escola
+ ", anoLetivo=" + anoLetivo + ", dtExclusao=" + dtExclusao
+ ", idUsuarioInseriu=" + idUsuarioInseriu
+ ", usuarioInseriu=" + usuarioInseriu + ", idUsuarioExcluiu="
+ idUsuarioExcluiu + ", usuarioExcluiu=" + usuarioExcluiu
+ ", obs=" + obs + "]";
}
public String getIdMatricula() {
return idMatricula;
}
public void setIdMatricula(String idMatricula) {
this.idMatricula = idMatricula;
}
public String getTipoEnsino() {
return tipoEnsino;
}
public void setTipoEnsino(String tipoEnsino) {
this.tipoEnsino = tipoEnsino;
}
public String getSerie() {
return serie;
}
public void setSerie(String serie) {
this.serie = serie;
}
public String getTurma() {
return turma;
}
public void setTurma(String turma) {
this.turma = turma;
}
public String getTurno() {
return turno;
}
public void setTurno(String turno) {
this.turno = turno;
}
Chamada do Bussiness
public TransporteEscolarDTO customGet(String id) {
String sql=("select te.uuid_pessoa_transp_escolar as id, te.uuid_pessoa as idPessoa, p.no_pessoa as pessoa, te.dt_registro as dtRegistro from tb_pessoa_transporte_escolar te" +
" join tb_pessoa p on p.uuid_pessoa=te.uuid_pessoa" +
" join tb_matricula m on m.uuid_pessoa=te.uuid_pessoa join tb_turma t on t.uuid_turma=m.uuid_turma where te.uuid_pessoa_transp_escolar=:id and m.st_matricula=1");
SQLQuery query = this.session.createSQLQuery(sql);
query.setParameter("id", id);
System.out.println(query);
return (TransporteEscolarDTO) query.setResultTransformer(
Transformers.aliasToBean(TransporteEscolarDTO.class))
.uniqueResult();
}
Erro Console
load id...1
SQLQueryImpl(select te.uuid_pessoa_transp_escolar as id, te.uuid_pessoa as idPessoa, p.no_pessoa as pessoa, te.dt_registro as dtRegistro from tb_pessoa_transporte_escolar te join tb_pessoa p on p.uuid_pessoa=te.uuid_pessoa join tb_matricula m on m.uuid_pessoa=te.uuid_pessoa join tb_turma t on t.uuid_turma=m.uuid_turma where te.uuid_pessoa_transp_escolar=:id and m.st_matricula=1)
Hibernate:
select
te.uuid_pessoa_transp_escolar as id,
te.uuid_pessoa as idPessoa,
p.no_pessoa as pessoa,
te.dt_registro as dtRegistro
from
tb_pessoa_transporte_escolar te
join
tb_pessoa p
on p.uuid_pessoa=te.uuid_pessoa
join
tb_matricula m
on m.uuid_pessoa=te.uuid_pessoa
join
tb_turma t
on t.uuid_turma=m.uuid_turma
where
te.uuid_pessoa_transp_escolar=?
and m.st_matricula=1
17:48:58,218 ERROR [BasicPropertyAccessor] IllegalArgumentException in class: br.com.soft.siseduca.model.dto.TransporteEscolarDTO, setter method of property: dtRegistro
17:48:58,218 ERROR [BasicPropertyAccessor] expected type: java.util.Calendar, actual value: java.sql.Timestamp
17:48:58,218 DEBUG [DefaultExceptionMapper] find for exception class org.hibernate.PropertyAccessException
17:48:58,218 DEBUG [DefaultExceptionMapper] find for exception class java.lang.IllegalArgumentException
Jan 29, 2013 5:48:58 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [default] in context with path [/siseduca] threw exception
br.com.caelum.vraptor.InterceptionException: exception raised, check root cause for details: org.hibernate.PropertyAccessException: IllegalArgumentException occurred while calling setter of br.com.soft.siseduca.model.dto.TransporteEscolarDTO.dtRegistro
at br.com.caelum.vraptor.interceptor.ExecuteMethodInterceptor.intercept(ExecuteMethodInterceptor.java:96)
at br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler.execute(ToInstantiateInterceptorHandler.java:54)
at br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:54)
at br.com.caelum.vraptor.core.LazyInterceptorHandler.execute(LazyInterceptorHandler.java:61)
at br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:54)
at br.com.soft.siseduca.interceptor.PermissionInterceptor.intercept(PermissionInterceptor.java:53)
at br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler.execute(ToInstantiateInterceptorHandler.java:54)
at br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:54)
at br.com.caelum.vraptor.interceptor.InstantiateInterceptor.intercept(InstantiateInterceptor.java:48)
at br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler.execute(ToInstantiateInterceptorHandler.java:54)
at br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:54)
at br.com.caelum.vraptor.interceptor.ExceptionHandlerInterceptor.intercept(ExceptionHandlerInterceptor.java:71)
at br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler.execute(ToInstantiateInterceptorHandler.java:54)
at br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:54)
at br.com.caelum.vraptor.interceptor.FlashInterceptor.intercept(FlashInterceptor.java:83)
at br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler.execute(ToInstantiateInterceptorHandler.java:54)
at br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:54)
at br.com.caelum.vraptor.interceptor.ParametersInstantiatorInterceptor.intercept(ParametersInstantiatorInterceptor.java:93)
at br.com.caelum.vraptor.core.LazyInterceptorHandler.execute(LazyInterceptorHandler.java:59)
at br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:54)
at br.com.caelum.vraptor.interceptor.ResourceLookupInterceptor.intercept(ResourceLookupInterceptor.java:69)
at br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler.execute(ToInstantiateInterceptorHandler.java:54)
at br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:54)
at br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler.execute(ToInstantiateInterceptorHandler.java:56)
at br.com.caelum.vraptor.core.DefaultInterceptorStack.next(DefaultInterceptorStack.java:54)
at br.com.caelum.vraptor.core.EnhancedRequestExecution.execute(EnhancedRequestExecution.java:44)
at br.com.caelum.vraptor.VRaptor$1.insideRequest(VRaptor.java:91)
at br.com.caelum.vraptor.ioc.spring.SpringProvider.provideForRequest(SpringProvider.java:58)
at br.com.caelum.vraptor.VRaptor.doFilter(VRaptor.java:88)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:225)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1001)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:585)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: org.hibernate.PropertyAccessException: IllegalArgumentException occurred while calling setter of br.com.soft.siseduca.model.dto.TransporteEscolarDTO.dtRegistro
at org.hibernate.property.BasicPropertyAccessor$BasicSetter.set(BasicPropertyAccessor.java:128)
at org.hibernate.transform.AliasToBeanResultTransformer.transformTuple(AliasToBeanResultTransformer.java:91)
at org.hibernate.hql.HolderInstantiator.instantiate(HolderInstantiator.java:96)
at org.hibernate.loader.custom.CustomLoader.getResultList(CustomLoader.java:361)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2276)
at org.hibernate.loader.Loader.list(Loader.java:2271)
at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:316)
at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1842)
at org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:165)
at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:157)
at org.hibernate.impl.AbstractQueryImpl.uniqueResult(AbstractQueryImpl.java:890)
at br.com.soft.siseduca.business.TransporteEscolarBusiness.customGet(TransporteEscolarBusiness.java:205)
at br.com.soft.siseduca.controller.TransporteEscolarController.load(TransporteEscolarController.java:122)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at br.com.caelum.vraptor.interceptor.ExecuteMethodInterceptor.intercept(ExecuteMethodInterceptor.java:61)
... 44 more
Caused by: java.lang.IllegalArgumentException: argument type mismatch
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.hibernate.property.BasicPropertyAccessor$BasicSetter.set(BasicPropertyAccessor.java:66)
... 61 more
Agradeço desde já!