ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tim Christopher <tim.christop...@gmail.com>
Subject Null properties
Date Sun, 27 Feb 2005 18:24:07 GMT
Hi,

I've got a table with 1 column that has 3 rows of data.  When I run my
app it returns a Collection of object of the correct type but whose
fields (there is only one field) are null...  So in the page that
loads if I iterate the collection it prints something like: The next
value is , The next value is , The next value is. [3 times - one per
row of db].

This is my sqlMap, and :

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE sqlMap PUBLIC "-//iBATIS.com//DTD SQL Map 2.0//EN"
"http://www.ibatis.com/dtd/sql-map-2.dtd">
<sqlMap namespace="ModuleLevel">
  <typeAlias alias="moduleLevel" type="com.domain.ModuleLevel"/>
  <cacheModel id="module_level_cache" type="LRU" readOnly="true">
    <flushInterval hours="24" />
  </cacheModel>
  <resultMap id="moduleLevelResult" class="moduleLevel">
    <result property="level" column="LEVEL_NO"/>
  </resultMap>
  <select id="getModuleLevelList" resultClass="moduleLevel">
    <![CDATA[
    select LEVEL_NO from MODULE_LEVEL
    ]]>
  </select>
</sqlMap>

My ModuleLevel domain object contains an empty constructor and a
private variable 'level', along the a get and set method for it

I have tested it within my Java (Struts) Action file using the following code:

    List levels = moduleLevelService.getModuleLevelList();
    if (levels.get(0) instanceof ModuleLevel) {
      System.out.println ("This line is always printed");
    }
    ModuleLevel a = (ModuleLevel) t_levels.get(0);
    System.out.println ("This always prints null: " + a.getLevel());
    System.out.println ("This always prints 3: " + levels.size());

Has anyone got any ideas?  I've spent hours looking at it, and I'm
sure it's only some silly mistake that's causing the problem :-(

Tim Christopher

Mime
View raw message