Hello, guys.
I have a very strange problem ( for me, I'm a newbie in hibernate-jpa). I have readed papers and documentation but I can't found a solution.
I'm going to explain my problem:
I have created this query:
Code:
@NamedNativeQueries({
@NamedNativeQuery(name = "DatosAcademicos.findDatosAcademicosByIdSolicitante", query = "SELECT da.DATO_ACADEMICO_ID,da.CURSO_ACADEMICO"
+ " FROM Datos_Academicos da WHERE da.SOLICITANTE_ID=:solicitanteId", resultClass = DatosAcademicos.class)
})
My Entity has 3 parameters:
Code:
public class DatosAcademicos extends GeneralDomainObject implements
Serializable {
/**
*
*/
private static final long serialVersionUID = 4463742762840808393L;
@Id
@Column(name = "DATO_ACADEMICO_ID")
private Long datoAcademicoId;
@Column(name = "CURSO_ACADEMICO")
private Integer cursoAcademico;
@Column(name = "CONFIRMADA")
private Integer confirmada;
}
Hibernate always say to me:
could not read column value from result set: CONFIRMADA; Nombre de columna no vĂ¡lido.
This is my execution:
Code:
public List<DatosAcademicos> findDatosAcademicosByIdSolicitante(
Long idSolicitante) throws GeneralDAOException {
try {
return (List<DatosAcademicos>) getJpaTemplate()
.getEntityManager()
.createNamedQuery(
"DatosAcademicos.findDatosAcademicosByIdSolicitante")
.setParameter(
"solicitanteId",
(idSolicitante != null ? idSolicitante
: Long.MIN_VALUE)).getResultList();
} catch (Exception e) {
logger.error("Error en DatosAcademicosDAOImpl " + e.getMessage());
throw new GeneralDAOException(e.getMessage(), e.getMessage(), e);
}
}
If I do query in this way:
Code:
@NamedNativeQueries({
@NamedNativeQuery(name = "DatosAcademicos.findDatosAcademicosByIdSolicitante", query = "SELECT da.*
+ " FROM Datos_Academicos da WHERE da.SOLICITANTE_ID=:solicitanteId", resultClass = DatosAcademicos.class)
all works fine; so... What's the problem here?.
Does hibernate allow get only 1 column in native query binding it to an object?.
Thanks in advance.
English is not my native language, sorry for my poor way of writing. :(