ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tommy Kristiansen <to...@commfides.com>
Subject where with multiple where conditions.. ERROR
Date Mon, 11 Dec 2006 09:37:21 GMT

Hi, 

A short question. I get an Error while sending a Select statement with
multiple where conditions in iBatis.  I've seen me blind on the problem so I
thought I’ll try you. So I would be pleased if you used a minute or two. 

Below  it’s clips form the files I use and it’s works with other select
statements that only have one where condition.

Just post i you need more information 

The call that fails here..

pinorderLast      =     pinorderDAO.getLastPinOrder(fnr, partnerCode);
logger.debug("Cert wizard 1::: pinorderLast"+pinorderLast.toString());

 

Error log from server.

As you can see from the log it’ sends [03117733344, 03117733344] as
parameters it should have been [03127634725, 1], so the error is because it
don’t get a object back But still it send the wrong parameters. Can you see
why?? And you see it sends right parameters in below.

 

2006-12-05 16:04:29,796 DEBUG
[com.commfides.servlets.RequestCertficateServlet] Cert wizard 1::: 

IDENTIFY fnr=03117733344 partnerCode=1

2006-12-05 16:04:30,516 DEBUG [com.ibatis.common.jdbc.SimpleDataSource]
Created connection 25631337.

2006-12-05 16:04:30,516 DEBUG [com.ibatis.common.jdbc.SimpleDataSource]
Testing connection 25631337...

2006-12-05 16:04:30,516 DEBUG [com.ibatis.common.jdbc.SimpleDataSource]
Connection 25631337 is GOOD!

2006-12-05 16:04:30,520 DEBUG [java.sql.Connection] {conn-100000} Connection

2006-12-05 16:04:30,551 DEBUG [java.sql.PreparedStatement] {pstm-100001}
PreparedStatement:     SELECT      ID_PINORDER   as      idPinOrder,     
FNR      as  fnr,      FIRST_NAME    as  firstName,      LAST_NAME     as 
lastName,      ADDRESS     as  address,      ZIP      as  zip,      CITY     
as  city,            PIN_DATE    as  pinDate,      PINS     as  pins,     
PINS_STATUS   as  pinsStatus,      ID_PARTNER    as      partnerCode    FROM
PIN_ORDER     WHERE FNR = ?     AND ID_PARTNER = ?    ORDER BY PIN_DATE DESC
LIMIT 1

2006-12-05 16:04:30,551 DEBUG [java.sql.PreparedStatement] {pstm-100001}
Parameters: [03127634725, 03127634725]

2006-12-05 16:04:30,552 DEBUG [java.sql.PreparedStatement] {pstm-100001}
Types: [java.lang.String, java.lang.String]

2006-12-05 16:04:30,554 DEBUG [java.sql.ResultSet] {rset-100002} ResultSet

2006-12-05 16:04:30,568 DEBUG [com.ibatis.common.jdbc.SimpleDataSource]
Testing connection 25631337...

2006-12-05 16:04:30,568 DEBUG [com.ibatis.common.jdbc.SimpleDataSource]
Connection 25631337 is GOOD!

2006-12-05 16:04:30,568 DEBUG [com.ibatis.common.jdbc.SimpleDataSource]
Returned connection 25631337 to pool.

2006-12-05 16:04:30,571 ERROR
[com.commfides.servlets.RequestCertficateServlet]

java.lang.NullPointerException

        at
com.commfides.servlets.RequestCertficateServlet.doWork(RequestCertficateServlet.java:74)

        at
com.commfides.servlets.RequestCertficateServlet.doPost(RequestCertficateServlet.java:386)

 

 

PinOrder.java

 

public class PinOrder implements Serializable {

    private int idPinOrder;

      private String fnr;

      private String firstName;

      private String middleName;

      private String lastName;

      private String address;

      private int zip;

      private String city;

      private Timestamp pinDate;

      private String pins;

      private String pinsStatus;

      private int partnerCode;

 

 

 

 

PinOrderDAO.java

 

public interface PinOrderDAO {

 

      public PinOrder getLastPinOrder(String fnr, int partnerCode) throws
SQLException;

 

 

 

PinOrderDAOiBatis.java

 

public class PinOrderDAOiBatis implements PinOrderDAO {

 

      public PinOrder getLastPinOrder(String fnr, int partnerCode)throws
SQLException {

            SqlMapClient sqlMap = DBConfig.getSqlMapClientInstance();

            PinOrder pinorder =  (PinOrder)
sqlMap.queryForObject("getLastPinOrder",fnr,partnerCode);

            return pinorder;

}     

 

PinOrder.xml

 

<?xml version="1.0" encoding="UTF-8" ?>

<!DOCTYPE sqlMap PUBLIC "-//iBATIS.com//DTD SQL Map 2.0//EN"
"http://www.ibatis.com/dtd/sql-map-2.dtd">

 

<sqlMap namespace="PinOrder">

      <select id="getLastPinOrder" resultClass="com.commfides.dao.PinOrder">

                  SELECT

                         ID_PINORDER                 as      idPinOrder,

                         FNR                         as          fnr,

                         FIRST_NAME                  as          firstName,

                         LAST_NAME                   as          lastName,

                         ADDRESS                     as          address,

                         ZIP                         as          zip,

                         CITY                              as          city,

                         <!-- REQUEST_DATE                 as         
pinDate, -->

                         PIN_DATE                    as          pinDate,

                         PINS                        as          pins,

                         PINS_STATUS                 as          pinsStatus,

                         ID_PARTNER                  as      partnerCode

                  FROM PIN_ORDER 

                  WHERE FNR = #fnr# 

                  AND ID_PARTNER = #partnerCode#

                  ORDER BY PIN_DATE DESC LIMIT 1

      </select>


-- 
View this message in context: http://www.nabble.com/where-with-multiple-where-conditions..-ERROR-tf2792846.html#a7791772
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.


Mime
View raw message