ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Warren <war...@clarksnutrition.com>
Subject n+1 Problem NullPointerException
Date Fri, 01 Dec 2006 03:32:12 GMT
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:


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" 
   <result property="catName" column="cat_name" javaType="string" 
   <result property="items" javaType="java.util.List" 
resultMap="CatItem.itemsResults" />
<resultMap id="itemsResults" class="testItem" >
  <result property="itemName" column="itm_name" javaType="string" 

<select id="getCatWithItems" resultMap="catItemsResults"
  SELECT cat_pk, cat_name, itm_name FROM testcat LEFT JOIN testitem ON 
cat_pk = itm_cat_fk

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?



View raw message