I am having problems with an n+1 sql map. I am getting the following
error messages:
--- The error occurred while applying a result map.
--- Check the CatItem.catItemsResults.
--- Check the result mapping for the 'items' property.
--- Cause: java.lang.NullPointerException
I have put the following test together:
Objects
TestCat object
private int catPK;
private String catName;
private List items;
TestItem object
private int itemPK;
private String itemName;
Database Tables
testitem table
itm_pk int4,
itm_cat_fk int4,
itm_name char(20),
testcat table
cat_pk int4,
cat_name char(20)
<resultMap id="catItemsResults" class="testCat" groupBy="catPK" >
<result property="catPK" column="cat_pk" javaType="int"
jdbcType="INTEGER"/>
<result property="catName" column="cat_name" javaType="string"
jdbcType="CHAR"/>
<result property="items" javaType="java.util.List"
resultMap="CatItem.itemsResults" />
</resultMap>
<resultMap id="itemsResults" class="testItem" >
<result property="itemName" column="itm_name" javaType="string"
jdbcType="CHAR"/>
</resultMap>
<select id="getCatWithItems" resultMap="catItemsResults"
SELECT cat_pk, cat_name, itm_name FROM testcat LEFT JOIN testitem ON
cat_pk = itm_cat_fk
</select>
I have looked at the FAQ, docs and mailing list archive and I can not
figure out what I am doing wrong. I have tried it on a Postgres db with
a postgres driver and a Sybase db with an ODBC driver. I still get the
same results. I am running version 2.1.7 of Ibatis. What am I doing wrong?
Thanks,
Warren