Cheers, that was it!

Turns out as I just copy an old SQLMap to use as a starting point for
each new one (as they have a lot in common) the one I origonally
copied had an error in!  However the origonal one still worked at the
db and the java object had the same names for the attributes.

Guess I'll know better for next time...  Though if it was trying to
call setLevelNo(..) I'd have thought this would have thrown an error
during the build or at runtime, as that method doesn't exist.

Tim Christopher

On Sun, 27 Feb 2005 13:53:11 -0500, Phil Barnes
<[EMAIL PROTECTED]> wrote:
> You have
> 
> <select id="getModuleLevelList" resultClass="moduleLevel"
> 
> specified, instead of probably meaning
> 
> <select id="getModuleLevelList" resultMap="moduleLevelResult"
> 
> The former way you currnetly have, would look for a "setLevelNo(..)"
> method in your class (to correspond with the LEVEL_NO column), and
> therefore "level" would be empty.
> 
> HTH.
> 
> On Sun, 27 Feb 2005 18:24:07 +0000, Tim Christopher
> <[EMAIL PROTECTED]> wrote:
> > 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
> >
>

Reply via email to