Richard,
That worked.  After it worked I started gradually adding other parts of my
original query back in to try to find the point of failure.  I eventually
arrived back at my original query, and it worked properly.  So, the point of
failure must have been somewhere else, and I have no idea how it was
resolved or when.  Maybe my xml file wasn't updating on redeployments,
that's the only thing I can think of.

Anyway, thanks to both Larry and Richard for taking the time to look at my
problem.  I wish I could find out what the original problem was.  I'll give
an update if I can track it down.

David

-----Original Message-----
From: Richard Yee [mailto:[EMAIL PROTECTED] 
Sent: Thursday, May 01, 2008 10:43 PM
To: [email protected]
Subject: Re: DAO class not getting values from query

David,
Since you are doing a join on the tables, I suggest either using column or
columnIndex in your result tags but not both.
If you use column, you should change the select to 
<select id="getAirportList" resultMap="result">
        SELECT
                AIRPORT.AIRPORT_ID AS AIRPORT_ID,
                AIRPORT.IATA_CODE AS IATA_CODE,
                AIRPORT.ICAO_CODE AS ICAO_CODE,
                AIRPORT.LATITUDE AS LATITUDE,
                AIRPORT.LONGITUDE AS LONGITUDE,
                AIRPORT.START_DATE AS START_DATE,
                AIRPORT.END_DATE AS END_DATE,
                AIRPORT_NAME.NAME AS NAME
        FROM AIRPORT, AIRPORT_NAME
        WHERE AIRPORT.AIRPORT_ID = AIRPORT_NAME.AIRPORT_ID
                AND AIRPORT_NAME.MAIN_FLG = 1
        </select>


<sqlMap namespace="Airport">
        <resultMap id="result" class="domain.Airport">
                <result property="id" javaType="Integer" jdbcType="NUMBER"
column="AIRPORT_ID"/>
                <result property="iataCode" javaType="String"
jdbcType="CHAR(3)" column="IATA_CODE"/>
                <result property="icaoCode" javaType="String"
jdbcType="CHAR(4)" column="ICAO_CODE"/>
                <result property="latitude" javaType="Integer"
jdbcType="NUMBER" column="LATITUDE"/>
                <result property="longitude" javaType="Integer"
jdbcType="NUMBER" column="LONGITUDE"/>
                <result property="startDate" javaType="String"
jdbcType="TIMESTAMP" column="START_DATE"/>
                <result property="endDate" javaType="String"
jdbcType="TIMESTAMP" column="END_DATE"/>
                <result property="name" javaType="String"
jdbcType="VARCHAR2" column="NAME"/>
        </resultMap>

Use of the jdbcType attribute is also not really necessary in this case
either.

-Richard



David Momper wrote:
> Hi all,
> I have a page that displays a list or airports from a database query.  The
> page displays the correct database values from some fields, null values
from
> others. Through debugging, I have figured out that the fields that display
> as null are never set to begin with, but as best I can tell, they should
be.
>
> Some of the fields with problems are identical in structure to fields with
> no problems. Latitude/longitude, and airport id are all Integers in my
java
> class, and are NUMBER in Oracle.  Lat/lon get proper values, id remains
> null.  Of the fields I query, only latitude, longitude, and name get
> non-null values.  I have verified that if I directly perform the query
> against the database, all proper values are returned, so the query is not
my
> problem.  I suspect that the problem lies in my resultMap, but I haven't
> been able to figure out what is wrong there.
>
> I use Ibatis and Spring, with an Oracle 10g database. Relevant code is
> included below.  Any help would be greatly appreciated.
>
> The SQL map xml file:
> <sqlMap namespace="Airport">
>       <resultMap id="result" class="domain.Airport">
>               <result property="id" javaType="Integer" jdbcType="NUMBER"
> column="AIRPORT_ID" columnIndex="1"/>
>               <result property="iataCode" javaType="String"
> jdbcType="CHAR(3)" column="IATA_CODE" columnIndex="2"/>
>               <result property="icaoCode" javaType="String"
> jdbcType="CHAR(4)" column="ICAO_CODE" columnIndex="3"/>
>               <result property="latitude" javaType="Integer"
> jdbcType="NUMBER" column="LATITUDE" columnIndex="4"/>
>               <result property="longitude" javaType="Integer"
> jdbcType="NUMBER" column="LONGITUDE" columnIndex="5"/>
>               <result property="startDate" javaType="String"
> jdbcType="TIMESTAMP" column="START_DATE" columnIndex="6"/>
>               <result property="endDate" javaType="String"
> jdbcType="TIMESTAMP" column="END_DATE" columnIndex="7"/>
>               <result property="name" javaType="String"
> jdbcType="VARCHAR2" column="NAME" columnIndex="8"/>
>       </resultMap>
>       <select id="getAirportList" resultClass="domain.Airport">
>       SELECT
>               AIRPORT.AIRPORT_ID,
>               AIRPORT.IATA_CODE,
>               AIRPORT.ICAO_CODE,
>               AIRPORT.LATITUDE,
>               AIRPORT.LONGITUDE,
>               AIRPORT.START_DATE,
>               AIRPORT.END_DATE,
>               AIRPORT_NAME.NAME
>       FROM AIRPORT, AIRPORT_NAME
>       WHERE AIRPORT.AIRPORT_ID = AIRPORT_NAME.AIRPORT_ID
>               AND AIRPORT_NAME.MAIN_FLG = 1
>       </select>
> </sqlMap>
>
> AirportSqlMapDao class has:
> public List<Airport> getAirportList() {
>       return
> (List<Airport>)getSqlMapClientTemplate().queryForList("getAirportList");
> }
>
> The fields from the Airport class.  Getter/setter methods are typical
> getter/setters.
> private Integer id;
>       private String name;
>       private String iataCode;
>       private String icaoCode;
>       private Integer latitude;
>       private Integer longitude;
>       private String startDate, endDate;
>
>
> My manager class:
> public class SimpleAirportManager implements AirportManager {
> private AirportDao airportDao;
>     public List<Airport> getAirports() {
>         return airportDao.getAirportList();
>     }
>     public void setAirportDao(AirportDao airportDao) {
>         this.airportDao = airportDao;
>     }
> }
>
> My controller has the code:
> public ModelAndView handleRequest(HttpServletRequest request,
> HttpServletResponse response) throws ServletException, IOException {
>         Map<String, Object> myModel = new HashMap<String, Object>();
>         myModel.put("airports", this.airportManager.getAirports());
>         return new ModelAndView("hello", "model", myModel);
> }
>
> This is the code from the display page:
> <table border=1>
> <tr><td>ID</td><td>Name</td><td>IATA code</td><td>ICAO
> code</td><td>Latitude</td><td>Longitude</td><td>Start Date</td><td>End
> Date</td></tr>
> <c:forEach items="${model.airports}" var="arpt">
> <tr>
> <td><c:out value="${arpt.id}"/></td>
> <td><c:out value="${arpt.name}"/></td>
> <td><c:out value="${arpt.iataCode}"/></td>
> <td><c:out value="${arpt.icaoCode}"/></td>
> <td><c:out value="${arpt.latitude}"/></td>
> <td><c:out value="${arpt.longitude}"/></td>
> <td><c:out value="${arpt.startDate}"/></td>
> <td><c:out value="${arpt.endDate}"/></td>
> </tr>
> </c:forEach>
> </table>
>
>
>   


Reply via email to