Isaac Vásquez (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=627d288...
) *created* an issue
Hibernate ORM (
https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiMmMwMDNjMDg2...
) / Bug (
https://hibernate.atlassian.net/browse/HHH-16697?atlOrigin=eyJpIjoiMmMwMD...
) HHH-16697 (
https://hibernate.atlassian.net/browse/HHH-16697?atlOrigin=eyJpIjoiMmMwMD...
) CALCULATED FIELDS in createNativeQuery doExtract integer insted of BigDecimals. (
https://hibernate.atlassian.net/browse/HHH-16697?atlOrigin=eyJpIjoiMmMwMD...
)
Issue Type: Bug Affects Versions: 6.2.0, 6.2.1, 6.2.2, 6.2.3 Assignee: Unassigned
Components: hibernate-core Created: 25/May/2023 10:19 AM Environment: Hibernate-core
6.2.2.Final
Java 17
Jakarta 10
Spring Boot 3.1.0
Priority: Major Reporter: Isaac Vásquez (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=627d288...
)
Having the following code:
@Override
public ArrayList< Object []> getEncMorososNotificados( String pTipo, String
pFechaInicio, String pFechaFin, String pNotificador) {
Session session = sessionFactory.getCurrentSession();
StringBuilder consulta = new StringBuilder();
String vNotificador = "";
if (pTipo.equals( "3" )) {
vNotificador = pNotificador;
}
try {
consulta.append("""
SELECT C.NUM_NOTIFICACION, C.NUM_AVISO, C.GIS, C.CEDULA,
C.RAZON_SOCIAL, C.TELEFONO, C.FEC_NOTIFICACION, C.ENTREGADO, C.FEC_ENTREGA,
C.COD_NOTIFICADOR, C.OBSERVACION, C.USUA_REGIST, C.NO_ENTREGADO, C.FEC_NO_ENTREGADO, \
C.FEC_DESBLOQUEO, SUM(SERV_TRIBUTARIOS.FNC_NOTIFICACION_COBRO (C.GIS,
C.CEDULA, C.NUM_AVISO, TO_NUMBER (C.NUM_NOTIFICACION), NULL, 3)) NOTIFICADO, \
SUM(SERV_TRIBUTARIOS.FNC_NOTIFICACION_COBRO (C.GIS, C.CEDULA,
C.NUM_AVISO, TO_NUMBER (C.NUM_NOTIFICACION), NULL, 1)) PENDIENTE, \
SUM(SERV_TRIBUTARIOS.FNC_NOTIFICACION_COBRO (C.GIS, C.CEDULA,
C.NUM_AVISO, TO_NUMBER (C.NUM_NOTIFICACION), C.NUM_PAGO, 4)) CANCELADO, \
SUM(SERV_TRIBUTARIOS.FNC_NOTIFICACION_COBRO (C.GIS, C.CEDULA,
C.NUM_AVISO, TO_NUMBER (C.NUM_NOTIFICACION), C.NUM_PAGO, 5)) ELIMINADO \
FROM (SELECT DISTINCT A.NUM_NOTIFICACION, A.NUM_AVISO, D.GIS, D.CEDULA,
A.RAZON_SOCIAL, A.TELEFONO, TO_CHAR (A.FEC_NOTIFICACION, 'YYYY-MM-DD' )
FEC_NOTIFICACION, A.ENTREGADO, TO_CHAR (A.FEC_ENTREGA, 'YYYY-MM-DD' ) FEC_ENTREGA,
\
A.COD_NOTIFICADOR, A.OBSERVACION, A.USUA_REGIST, A.NO_ENTREGADO,
TO_CHAR (A.FEC_NO_ENTREGADO, 'YYYY-MM-DD' ) FEC_NO_ENTREGADO, TO_CHAR
(A.FEC_DESBLOQUEO, 'YYYY-MM-DD' ) FEC_DESBLOQUEO, D.NUM_PAGO \
FROM SERV_TRIBUTARIOS.NOTIF_AVISO_COBRO_ENC A,
SERV_TRIBUTARIOS.NOTIF_AVISO_COBRO_DET D \
WHERE A.COD_CIA = '01' \
AND D.CEDULA = A.CEDULA \
AND A.NUM_NOTIFICACION = D.NUM_NOTIFICACION \
AND A.NUM_AVISO = D.NUM_AVISO \
AND D.CEDULA NOT IN (SELECT DISTINCT CEDULA FROM
MUNI.EXCLU_CED_LISTADOS WHERE TIPO_PROCESO = '01' ) \
AND A.COD_NOTIFICADOR = NVL(:pNotificador, A.COD_NOTIFICADOR)\
""");
switch (pTipo) {
case "1" :
consulta.append("""
AND A.FEC_ENTREGA BETWEEN TO_DATE(:pFechaInicio,
'YYYY-MM-DD' ) AND TO_DATE(:pFechaFin, 'YYYY-MM-DD' ) \
AND NVL(A.ENTREGADO, 'N' ) = 'S' \
ORDER BY A.NUM_NOTIFICACION) C \
""");
break ;
case "2" :
consulta.append("""
AND A.FEC_NOTIFICACION BETWEEN TO_DATE(:pFechaInicio,
'YYYY-MM-DD' ) AND TO_DATE(:pFechaFin, 'YYYY-MM-DD' ) \
AND NVL(A.NO_ENTREGADO, 'N' ) = 'S' \
ORDER BY A.NUM_NOTIFICACION) C \
""");
break ;
case "3" :
consulta.append("""
AND A.FEC_NOTIFICACION BETWEEN TO_DATE(:pFechaInicio,
'YYYY-MM-DD' ) AND TO_DATE(:pFechaFin, 'YYYY-MM-DD' ) \
ORDER BY D.CEDULA, A.NUM_AVISO) C \
""");
break ;
default :
break ;
}
consulta.append("""
GROUP BY C.NUM_NOTIFICACION, C.NUM_AVISO, C.GIS, C.CEDULA,
C.RAZON_SOCIAL, C.TELEFONO, C.FEC_NOTIFICACION, C.ENTREGADO, C.FEC_ENTREGA,
C.COD_NOTIFICADOR, C.OBSERVACION, C.USUA_REGIST, \
C.NO_ENTREGADO, C.FEC_NO_ENTREGADO, C.FEC_DESBLOQUEO\
""");
Query objQuery = session.createNativeQuery(consulta.toString(), Object.class);
objQuery.setParameter( "pFechaInicio" , pFechaInicio);
objQuery.setParameter( "pFechaFin" , pFechaFin);
objQuery.setParameter( "pNotificador" , vNotificador);
objQuery.setCacheable( true );
return (ArrayList< Object []>) objQuery.list();
} catch (HibernateException ex) {
throw LoggerManager.throwException(ex);
}
}
All the calculated fields, ex.
SUM(SERV_TRIBUTARIOS.FNC_NOTIFICACION_COBRO (C.GIS, C.CEDULA, C.NUM_AVISO, TO_NUMBER
(C.NUM_NOTIFICACION), NULL, 1)) PENDIENTE
Are returning Integer data, but the expected field have decimals.
Debugging a little the excecution, what I can see is that the “doExtract“ is calling the
IntegerJdbcType for some reason ( The trace below was generated with the intention of
seeing what was going on, the actual execution is error free )
at
oracle.jdbc.driver.GeneratedScrollableResultSet.getInt(GeneratedScrollableResultSet.java:246)
at
org.hibernate.type.descriptor.jdbc.IntegerJdbcType$2.doExtract(IntegerJdbcType.java:88)
at org.hibernate.type.descriptor.jdbc.BasicExtractor.extract(BasicExtractor.java:44)
at
org.hibernate.sql.results.jdbc.internal.JdbcValuesResultSetImpl.readCurrentRowValues(JdbcValuesResultSetImpl.java:262)
(
https://hibernate.atlassian.net/browse/HHH-16697#add-comment?atlOrigin=ey...
) Add Comment (
https://hibernate.atlassian.net/browse/HHH-16697#add-comment?atlOrigin=ey...
)
Get Jira notifications on your phone! Download the Jira Cloud app for Android (
https://play.google.com/store/apps/details?id=com.atlassian.android.jira....
) or iOS (
https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=Em...
) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100225- sha1:0428b75 )