Return-Path: Delivered-To: apmail-ibatis-user-java-archive@www.apache.org Received: (qmail 80160 invoked from network); 12 Jan 2006 13:40:28 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 12 Jan 2006 13:40:28 -0000 Received: (qmail 73175 invoked by uid 500); 12 Jan 2006 13:40:20 -0000 Delivered-To: apmail-ibatis-user-java-archive@ibatis.apache.org Received: (qmail 72926 invoked by uid 500); 12 Jan 2006 13:40:18 -0000 Mailing-List: contact user-java-help@ibatis.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user-java@ibatis.apache.org Delivered-To: mailing list user-java@ibatis.apache.org Received: (qmail 72915 invoked by uid 99); 12 Jan 2006 13:40:18 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 12 Jan 2006 05:40:18 -0800 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [217.33.142.51] (HELO mailout.flightcentre.co.uk) (217.33.142.51) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 12 Jan 2006 05:40:18 -0800 Message-id: Date: Thu, 12 Jan 2006 13:39:55 +0000 Subject: iBatis hangs query w/ multiple joins To: user-java@ibatis.apache.org From: "Jorge DeCastro" MIME-Version: 1.0 Content-type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Hi there, I'm using iBatis to access a SQLServer db and I'm running into the following problem. If I run the code below via straight JDBC it runs perfectly. private static final String SQL_STATEMENT = "SELECT DISTINCT "+ "TOP 10 " + " PubAir.PubAirID," + " PubAir.FromGeoAirPort," + " PubAir.ToGeoAirPort, " + " PubAirAgreement.ValidFromDate," + " PubAirAgreement.ValidToDate," + " PubAirPrice.ADTCostAmount," + " TAXEstimate.TaxAmount," + " TAXEstimate.CurrencyCode" + " FROM PubAirRoutingPrice" + " INNER JOIN PubAirPrice ON PubAirRoutingPrice.PubAirPriceID = PubAirPrice.PubAirPriceID" + " INNER JOIN PubAir INNER JOIN PubAirAgreement ON PubAir.PubAirAgreementID = PubAirAgreement.PubAirAgreementID" + " INNER JOIN PubAirRouting ON PubAir.PubAirID = PubAirRouting.PubAirID ON PubAirRoutingPrice.PubAirRoutingID = PubAirRouting.PubAirRoutingID" + " INNER JOIN TAXEstimate ON TAXEstimate.InboundFromGeoCode = dbo.PubAir.ToGeoAirPort" + " WHERE (PubAirPrice.ADTCostAmount > 0)" + " AND (PubAir.FromGeoAirPort LIKE ?)" + " AND (PubAir.ToGeoAirPort LIKE ?)"; public List findFaresFromToAirportsWithinDatesViaStraightJDBC( String fromAirport, String toAirport, String airlineFilter, String type, Date startDate, Date endDate, Integer records) { logger.debug("Retrieving '" + records + "' fares from '" + fromAirport + "' to '" + toAirport + "', start date '" + startDate + "', end date '" + endDate + "'"); DataSource ds = getDataSource(); Connection c = null; PreparedStatement ps = null; ArrayList l = new ArrayList(); try{ c = ds.getConnection(); ps = c.prepareStatement(SQL_STATEMENT); ps.setString(1, fromAirport + "%"); ps.setString(2, toAirport + "%"); ResultSet rs = ps.executeQuery(); while (rs.next()){ Air a = new Air(); a.setFromAirport(rs.getString("FromGeoAirPort")); a.setToAirport(rs.getString("ToGeoAirPort")); a.getAirPrice().setAdultCost(rs.getBigDecimal("ADTCostAmount")); a.getAirPrice().setTax(rs.getBigDecimal("TaxAmount")); l.add(a); } }catch(Exception e){ log.debug("error handling jdbc connection", e); }finally{ if (ps != null){ try{ ps.close(); }catch(Exception ignored){ } } if (c != null){ try{ c.close(); }catch(Exception ignored){ } } } logger.debug("Retrieved '" + l.size() + "' fares"); return l; } The same query running on the SQLServer client console works fine. Now if I run it through iBatis as I intend, the query hangs forever with no error reported on the logs. I'm buffled because it was my understandnig that iBatis was just doing the ResultSet wrapping and unwrapping for me, and nothing else fancy (like hibernate). Hence, it should simply execute a preparedStatement, populate the beans according to my settings, and return a list. Below are my mappings. Note that the "getCompanyCodes" query works just fine via iBatis, which seems to tell me iBatis is having problems with the joins. and on the java DAO: public List findFaresFromToAirportsWithinDates( String fromAirport, String toAirport, String airlineFilter, String type, Date startDate, Date endDate, Integer records) { Map parameters = new HashMap(); parameters.put("fromAirport", fromAirport + "%"); parameters.put("toAirport", toAirport + "%"); parameters.put("airlineFilter", airlineFilter + "%"); parameters.put("type", type + "%"); parameters.put("startDate", startDate); parameters.put("endDate", endDate); parameters.put("records", records); logger.debug("Retrieving '" + records + "' fares from '" + fromAirport + "' to '" + toAirport + "', start date '" + startDate + "', end date '" + endDate + "'"); List l = getSqlMapClientTemplate().queryForList( "findFaresFromToAirportsWithinDates", parameters); logger.debug("Retrieved '" + l.size() + "' fares"); return l; } Any help will be highly appreciated. chrs j.