Problem with a Long data type ------------------------------ Key: IBATIS-365 URL: http://issues.apache.org/jira/browse/IBATIS-365 Project: iBatis for Java Issue Type: Bug Affects Versions: 2.2.0 Environment: Windows XP Professional SP2. Eclipse 3.2.0. Java 1.5.0_09 Reporter: Javier Toyos Lanza
I have a problem with a java app. with spring + ibatis + oscache + database. In fact, I have a problem with a Long data type where the values are -1 and 0. I try to do : classApp.java { public static void main(String[] args) { ... Horario horario = horarioDAO.buscarHorario(new Long("-1")); ... Horario horario = horarioDAO.buscarHorario(new Long("0")); ... } } /------/ Interface HorarioDAO.java { ... public Horario buscarHorario(Long identificador) throws DAOException; ... } /-------/ HorarioDAOImpl extends SqlMapClientDaoSupport implements HorarioDAO { .... Horario buscarHorario(Long identificador) throws DAOException { ... SqlMapClientTemplate sqlMapClientTemplate = getSqlMapClientTemplate(); Horario horario = (Horario) sqlMapClientTemplate.queryForObject("Horario.buscarHorario", identificador); return horario; } .... } And Horario.xml <sqlMap namespace="Horario"> <cacheModel id="cacheHorarios" type="OSCACHE"> <flushInterval minutes="30"/> </cacheModel> <select id="buscarHorario" resultMap="horarioResult" parameterClass="java.lang.Long" cacheModel="cacheHorarios"> SELECT h.idhorario, h.nombre FROM horario h WHERE h.idhorario = #value# </select> </sqlMap> Finally the log: {conn-100000} Connection Connection.debug (lu00EDnea:27 ) {conn-100000} Preparing Statement: SELECT h.idhorario, h.nombre FROM horario h WHERE h.idhorario = ? Connection.debug (lu00EDnea:27 ) {pstm-100001} Executing Statement: SELECT h.idhorario, h.nombre FROM horario h WHERE h.idhorario = ? PreparedStatement.debug (lu00EDnea:27 ) {pstm-100001} Parameters: [-1] PreparedStatement.debug (lu00EDnea:27 ) {pstm-100001} Types: [java.lang.Long] PreparedStatement.debug (lu00EDnea:27 ) {rset-100002} ResultSet ResultSet.debug (lu00EDnea:27 ) {conn-100003} Connection Connection.debug (lu00EDnea:27 ) If I modified only one of values ( -1 by -2 for example ) works correctly. Also, if I modified the Long data type by String, for example View the log: {conn-100000} Connection Connection.debug (lu00EDnea:27 ) {conn-100000} Preparing Statement: SELECT h.idhorario, h.nombre FROM horario h WHERE h.idhorario = ? Connection.debug (lu00EDnea:27 ) {pstm-100001} Executing Statement: SELECT h.idhorario, h.nombre FROM horario h WHERE h.idhorario = ? PreparedStatement.debug (lu00EDnea:27 ) {pstm-100001} Parameters: [-2] PreparedStatement.debug (lu00EDnea:27 ) {pstm-100001} Types: [java.lang.Long] PreparedStatement.debug (lu00EDnea:27 ) {rset-100002} ResultSet ResultSet.debug (lu00EDnea:27 ) {conn-100003} Connection Connection.debug (lu00EDnea:27 ) {conn-100003} Preparing Statement: SELECT h.idhorario, h.nombre FROM horario h WHERE h.idhorario = ? Connection.debug (lu00EDnea:27 ) {pstm-100004} Executing Statement: SELECT h.idhorario, h.nombre FROM horario h WHERE h.idhorario = ? PreparedStatement.debug (lu00EDnea:27 ) {pstm-100004} Parameters: [0] PreparedStatement.debug (lu00EDnea:27 ) {pstm-100004} Types: [java.lang.Long] PreparedStatement.debug (lu00EDnea:27 ) {rset-100005} ResultSet ResultSet.debug (lu00EDnea:27 ) {rset-100005} Header: [IDHORARIO, NOMBRE] ResultSet.debug (lu00EDnea:27 ) {rset-100005} Result: [0, Ma\u005cu005cu00f1ana y Tarde] ResultSet.debug (lu00EDnea:27 ) Thanks a lot Javier Toyos Lanza -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira