I have a table Incidencia
with a CHAR (1 Byte) column visiblemovil
. This column has 2 possible values: "S" or "N" (yes/no, si/no in Spanish) that I want convert to boolean
using @Convert
annotation. This is my code:
Converter:
@Converter
public class SiNoToBooleanConverter implements AttributeConverter<Boolean, String> {
@Override
public String convertToDatabaseColumn(Boolean aBoolean) {
return aBoolean ? "S" : "N";
}
@Override
public Boolean convertToEntityAttribute(String s) {
return "S".equals(s);
}
}
Entity:
@FilterDef(name = "PREGINCIDENCIA_FILTRO_FECHA", parameters = @ParamDef(name = "ultimaFechaSinc", type = "date"))
@Entity
public class Incidencia {
private List<Incidenciapreguntas> preguntasList;
private Integer codincidencia;
private String descripcion;
private Double horasfinalizacion;
@Convert(converter = SiNoToBooleanConverter.class)
private Boolean visiblemovil;
private boolean tieneDocumentacion;
@Id
@Column(name = "CODINCIDENCIA")
public Integer getCodincidencia() {
return codincidencia;
}
public void setCodincidencia(Integer codincidencia) {
this.codincidencia = codincidencia;
}
@Basic
@Column(name = "DESCRIPCION")
public String getDescripcion() {
return descripcion;
}
public void setDescripcion(String descripcion) {
this.descripcion = descripcion;
}
@OneToMany(mappedBy = "incidencia")
@Filter(name = "PREGINCIDENCIA_FILTRO_FECHA", condition = "FMODIFICACION > :ultimaFechaSinc OR FMODIFICACION IS NULL")
public List<Incidenciapreguntas> getPreguntasList() {
return preguntasList;
}
public void setPreguntasList(List<Incidenciapreguntas> preguntasList) {
this.preguntasList = preguntasList;
}
@Transient
public boolean isTieneDocumentacion() {
return tieneDocumentacion;
}
public void setTieneDocumentacion(boolean tieneDocumentacion) {
this.tieneDocumentacion = tieneDocumentacion;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Incidencia that = (Incidencia) o;
if (codincidencia != null ? !codincidencia.equals(that.codincidencia) : that.codincidencia != null)
return false;
if (descripcion != null ? !descripcion.equals(that.descripcion) : that.descripcion != null) return false;
return true;
}
@Override
public int hashCode() {
int result = codincidencia != null ? codincidencia.hashCode() : 0;
result = 31 * result + (descripcion != null ? descripcion.hashCode() : 0);
return result;
}
@Basic
@Column(name = "HORASFINALIZACION")
public Double getHorasfinalizacion() {
return horasfinalizacion;
}
public void setHorasfinalizacion(Double horasfinalizacion) {
this.horasfinalizacion = horasfinalizacion;
}
// @Basic
@Column(name = "VISIBLEMOVIL")
public Boolean getVisiblemovil() {
return visiblemovil;
}
public void setVisiblemovil(Boolean visiblemovil) {
this.visiblemovil = visiblemovil;
}
}
When I execute a SELECT statement (with QueryDSL) I'm getting this error:
org.hibernate.exception.GenericJDBCException: Fail to convert to internal representation
javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: Fail to convert to internal representation
Repository:
@Repository
public class IncidenciasDAO extends BaseDAO {
public List<Incidencia> getIncidencias() {
QIncidencia qIncidencia = QIncidencia.incidencia;
JPAQuery query = new JPAQuery(entityManager);
List<Incidencia> incidencias = query.from(qIncidencia).list(qIncidencia);
return incidencias;
}
}
Full stacktrace
org.hibernate.exception.GenericJDBCException: Fallo al convertir a representación interna
javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: Fallo al convertir a representación interna
at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1377)
at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1300)
at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:266)
at com.mysema.query.jpa.impl.AbstractJPAQuery.getResultList(AbstractJPAQuery.java:222)
at com.mysema.query.jpa.impl.AbstractJPAQuery.list(AbstractJPAQuery.java:274)
at com.grupogimeno.senda.movbrigadas.daos.IncidenciasDAO.getIncidencias_aroundBody0(IncidenciasDAO.java:26)
at com.grupogimeno.senda.movbrigadas.daos.IncidenciasDAO$AjcClosure1.run(IncidenciasDAO.java:1)
at org.springframework.cache.aspectj.AbstractCacheAspect.ajc$around$org_springframework_cache_aspectj_AbstractCacheAspect$1$2bc714b5proceed(AbstractCacheAspect.aj:1)
at org.springframework.cache.aspectj.AbstractCacheAspect$1.invoke(AbstractCacheAspect.aj:61)
at org.springframework.cache.interceptor.CacheAspectSupport.execute(CacheAspectSupport.java:180)
at org.springframework.cache.aspectj.AbstractCacheAspect.ajc$around$org_springframework_cache_aspectj_AbstractCacheAspect$1$2bc714b5(AbstractCacheAspect.aj:65)
at com.grupogimeno.senda.movbrigadas.daos.IncidenciasDAO.getIncidencias(IncidenciasDAO.java:22)
at com.grupogimeno.senda.movbrigadas.daos.IncidenciasDAO$$FastClassByCGLIB$$bd07b3a2.invoke(<generated>)
at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:191)
at org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:689)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
at org.springframework.cache.interceptor.CacheInterceptor$1.invoke(CacheInterceptor.java:58)
at org.springframework.cache.interceptor.CacheAspectSupport.execute(CacheAspectSupport.java:213)
at org.springframework.cache.interceptor.CacheInterceptor.invoke(CacheInterceptor.java:66)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:622)
at com.grupogimeno.senda.movbrigadas.daos.IncidenciasDAO$$EnhancerByCGLIB$$4b7b3a28.getIncidencias(<generated>)
at com.grupogimeno.senda.movbrigadas.services.IncidenciasService.getIncidencias(IncidenciasService.java:22)
at com.grupogimeno.senda.movbrigadas.services.rest.IncidenciasResource.getIcidencias(IncidenciasResource.java:30)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at com.sun.jersey.spi.container.JavaMethodInvokerFactory$1.invoke(JavaMethodInvokerFactory.java:60)2015-03-10 10:53:05,785 WARN org.hibernate.engine.jdbc.spi.SqlExceptionHelper - SQL Error: 17059, SQLState: 99999
2015-03-10 10:53:05,792 ERROR org.hibernate.engine.jdbc.spi.SqlExceptionHelper - Fallo al convertir a representación interna
org.hibernate.exception.GenericJDBCException: Fallo al convertir a representación interna
at com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$TypeOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:185)
at com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:75)
at com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:302)
at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
at com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:108)
at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
at com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:84)
at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1480)
at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1411)
at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1360)
at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1350)
at com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:416)
at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:538)
at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:716)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)
at com.grupogimeno.senda.commons.filters.BaseBasicAuthLoginFilter.doFilter(BaseBasicAuthLoginFilter.java:64)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
at org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:230)
at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:326)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:923)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:547)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)
at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
Caused by: org.hibernate.exception.GenericJDBCException: Fallo al convertir a representación interna
at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:54)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:125)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:110)
at org.hibernate.engine.jdbc.internal.proxy.AbstractResultSetProxyHandler.continueInvocation(AbstractResultSetProxyHandler.java:108)
at org.hibernate.engine.jdbc.internal.proxy.AbstractProxyHandler.invoke(AbstractProxyHandler.java:81)
at $Proxy115.getBoolean(Unknown Source)
at org.hibernate.type.descriptor.sql.BitTypeDescriptor$2.doExtract(BitTypeDescriptor.java:69)
at org.hibernate.type.descriptor.sql.BasicExtractor.extract(BasicExtractor.java:65)
at org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:269)
at org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:265)
at org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:238)
at org.hibernate.type.AbstractStandardBasicType.hydrate(AbstractStandardBasicType.java:357)
at org.hibernate.persister.entity.AbstractEntityPersister.hydrate(AbstractEntityPersister.java:2705)
at org.hibernate.loader.Loader.loadFromResultSet(Loader.java:1544)
at org.hibernate.loader.Loader.instanceNotYetLoaded(Loader.java:1476)
at org.hibernate.loader.Loader.getRow(Loader.java:1376)
at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:643)
at org.hibernate.loader.Loader.doQuery(Loader.java:853)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:292)
at org.hibernate.loader.Loader.doList(Loader.java:2381)
at org.hibernate.loader.Loader.doList(Loader.java:2367)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2197)
at org.hibernate.loader.Loader.list(Loader.java:2192)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:470)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:355)
at org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:195)
at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1248)
at org.hibernate.internal.QueryImpl.list(QueryImpl.java:101)
at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:257)
... 61 more
Caused by: java.sql.SQLException: Fallo al convertir a representación interna
at oracle.jdbc.driver.CharCommonAccessor.getBoolean(CharCommonAccessor.java:185)
at oracle.jdbc.driver.T4CCharAccessor.getBoolean(T4CCharAccessor.java:697)
at oracle.jdbc.driver.OracleResultSetImpl.getBoolean(OracleResultSetImpl.java:640)
at oracle.jdbc.driver.OracleResultSet.getBoolean(OracleResultSet.java:386)
at com.mchange.v2.c3p0.impl.NewProxyResultSet.getBoolean(NewProxyResultSet.java:2391)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.hibernate.engine.jdbc.internal.proxy.AbstractResultSetProxyHandler.continueInvocation(AbstractResultSetProxyHandler.java:104)
... 86 more
javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: Fallo al convertir a representación interna
at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1377)
at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1300)
at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:266)
at com.mysema.query.jpa.impl.AbstractJPAQuery.getResultList(AbstractJPAQuery.java:222)
at com.mysema.query.jpa.impl.AbstractJPAQuery.list(AbstractJPAQuery.java:274)
at com.grupogimeno.senda.movbrigadas.daos.IncidenciasDAO.getIncidencias_aroundBody0(IncidenciasDAO.java:26)
at com.grupogimeno.senda.movbrigadas.daos.IncidenciasDAO$AjcClosure1.run(IncidenciasDAO.java:1)
at org.springframework.cache.aspectj.AbstractCacheAspect.ajc$around$org_springframework_cache_aspectj_AbstractCacheAspect$1$2bc714b5proceed(AbstractCacheAspect.aj:1)
at org.springframework.cache.aspectj.AbstractCacheAspect$1.invoke(AbstractCacheAspect.aj:61)
at org.springframework.cache.interceptor.CacheAspectSupport.execute(CacheAspectSupport.java:180)
at org.springframework.cache.aspectj.AbstractCacheAspect.ajc$around$org_springframework_cache_aspectj_AbstractCacheAspect$1$2bc714b5(AbstractCacheAspect.aj:65)
at com.grupogimeno.senda.movbrigadas.daos.IncidenciasDAO.getIncidencias(IncidenciasDAO.java:22)
at com.grupogimeno.senda.movbrigadas.daos.IncidenciasDAO$$FastClassByCGLIB$$bd07b3a2.invoke(<generated>)
at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:191)
at org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:689)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
at org.springframework.cache.interceptor.CacheInterceptor$1.invoke(CacheInterceptor.java:58)
at org.springframework.cache.interceptor.CacheAspectSupport.execute(CacheAspectSupport.java:213)
at org.springframework.cache.interceptor.CacheInterceptor.invoke(CacheInterceptor.java:66)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:622)
at com.grupogimeno.senda.movbrigadas.daos.IncidenciasDAO$$EnhancerByCGLIB$$4b7b3a28.getIncidencias(<generated>)
at com.grupogimeno.senda.movbrigadas.services.IncidenciasService.getIncidencias(IncidenciasService.java:22)
at com.grupogimeno.senda.movbrigadas.services.rest.IncidenciasResource.getIcidencias(IncidenciasResource.java:30)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at com.sun.jersey.spi.container.JavaMethodInvokerFactory$1.invoke(JavaMethodInvokerFactory.java:60)
at com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$TypeOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:185)
at com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:75)
at com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:302)
at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
at com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:108)
at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
at com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:84)
at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1480)
at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1411)
at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1360)
at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1350)
at com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:416)
at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:538)
at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:716)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)
at com.grupogimeno.senda.commons.filters.BaseBasicAuthLoginFilter.doFilter(BaseBasicAuthLoginFilter.java:64)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
at org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:230)
at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:326)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:923)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:547)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)
at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
Caused by: org.hibernate.exception.GenericJDBCException: Fallo al convertir a representación interna
at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:54)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:125)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:110)
at org.hibernate.engine.jdbc.internal.proxy.AbstractResultSetProxyHandler.continueInvocation(AbstractResultSetProxyHandler.java:108)
at org.hibernate.engine.jdbc.internal.proxy.AbstractProxyHandler.invoke(AbstractProxyHandler.java:81)
at $Proxy115.getBoolean(Unknown Source)
at org.hibernate.type.descriptor.sql.BitTypeDescriptor$2.doExtract(BitTypeDescriptor.java:69)
at org.hibernate.type.descriptor.sql.BasicExtractor.extract(BasicExtractor.java:65)
at org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:269)
at org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:265)
at org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:238)
at org.hibernate.type.AbstractStandardBasicType.hydrate(AbstractStandardBasicType.java:357)
at org.hibernate.persister.entity.AbstractEntityPersister.hydrate(AbstractEntityPersister.java:2705)
at org.hibernate.loader.Loader.loadFromResultSet(Loader.java:1544)
at org.hibernate.loader.Loader.instanceNotYetLoaded(Loader.java:1476)
at org.hibernate.loader.Loader.getRow(Loader.java:1376)
at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:643)
at org.hibernate.loader.Loader.doQuery(Loader.java:853)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:292)
at org.hibernate.loader.Loader.doList(Loader.java:2381)
at org.hibernate.loader.Loader.doList(Loader.java:2367)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2197)
at org.hibernate.loader.Loader.list(Loader.java:2192)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:470)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:355)
at org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:195)
at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1248)
at org.hibernate.internal.QueryImpl.list(QueryImpl.java:101)
at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:257)
... 61 more
Caused by: java.sql.SQLException: Fallo al convertir a representación interna
at oracle.jdbc.driver.CharCommonAccessor.getBoolean(CharCommonAccessor.java:185)
at oracle.jdbc.driver.T4CCharAccessor.getBoolean(T4CCharAccessor.java:697)
at oracle.jdbc.driver.OracleResultSetImpl.getBoolean(OracleResultSetImpl.java:640)
at oracle.jdbc.driver.OracleResultSet.getBoolean(OracleResultSet.java:386)
at com.mchange.v2.c3p0.impl.NewProxyResultSet.getBoolean(NewProxyResultSet.java:2391)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.hibernate.engine.jdbc.internal.proxy.AbstractResultSetProxyHandler.continueInvocation(AbstractResultSetProxyHandler.java:104)
... 86 more
What am I doing wrong?
Thanks.
You placed your mapping annotation on the getter for the mapped field in your entity class. According to chapter 2.3.1 of the specification, this leads to property-based access.
The specification states that only the getter should be annotated for the mapping. But perhaps that is not enough for the @Convert
annotation?
You could try to annotate the field:
@Entity
public class Incidencia {
@Column(name = "VISIBLE")
@Convert(converter = SiNoToBooleanConverter.class)
private Boolean visible;
//other fields
public Boolean getVisible() {
return visible;
}
public void setVisible(Boolean visible) {
this.visible = visible;
}
}
(I corrected the name of the variable/field in your getter/setter methods.)
Your converter looks correct. The only thing is the @Basic
annotation from your mapping. By definition, @Basic
tells that an attribute is going to be persisted and a standard mapping will be used, so this can be an issue (Also I don't see any strong reason to mix @Basic
and @Column
in your case).
@Column(name = "VISIBLE")
@Convert(converter = SiNoToBooleanConverter.class)
public Boolean getVisible() {
return visiblemovil;
}
Note: I haven't tested, but should solve the problem. Worth to try also moving annotations into the field, instead of getter.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With