You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by Stuart Piltch <st...@gradientblue.com> on 2005/05/18 17:32:50 UTC

ResultMap composite key problem

Hi there,

I recently added some resultMaps with composite keys as described in the
documentation: http://ibatisnet.sourceforge.net/DevGuide/ar01s03.html#d0e1064

I've done this successfully in iBatis before in other projects, but now I keep
getting a jdbc "Column not found" error (see below for some of the stack trace).
I'm using the new iBatis 2.1.0, but I've also tried the past few releases as
well. I've been trying to figure out what is different about this project than
the previous ones (which are still working fine).

Before I start copying and pasting large sections of the xml file, I thought I'd
start with asking if anyone has seen this error and knows what's causing it. If
it would help, I can start posting sections of the xml.

I'm using Mac OS X (10.3.9), Tomcat 5.0.29, MySQL 4.1.7, and iBatis 2.1.0. I've
tried it with lazy loading enabled and disabled and I've tried using a single
named key (eg column="{testId=test_id}") with the same results. It looks like
the {...} isn't being parsed by iBatis before being handed off to jdbc.

The single line that's causing problems is:

<result property="categories" column="{testId=test_id, asmtId=assessment_id}"
select="getCompetencyTypes" />

The error I get is: java.sql.SQLException: Column '{testId=test_id,
asmtId=assessment_id}' not found. at
com.mysql.jdbc.ResultSet.findColumn(ResultSet.java:2317) at
com.mysql.jdbc.ResultSet.getInt(ResultSet.java:1287) at
org.apache.commons.dbcp.DelegatingResultSet.getInt(DelegatingResultSet.java:236)
at sun.reflect.GeneratedMethodAccessor150.invoke(Unknown Source) at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.
java:25) at java.lang.reflect.Method.invoke(Method.java:324) at
com.ibatis.common.jdbc.logging.ResultSetLogProxy.invoke(ResultSetLogProxy.java:
47) at $Proxy7.getInt(Unknown Source) at
com.ibatis.sqlmap.engine.type.IntegerTypeHandler.getResult(IntegerTypeHandler.
java:35) at
com.ibatis.sqlmap.engine.mapping.result.BasicResultMap.
preparePrimitiveParameterObject(BasicResultMap.java:457) at
com.ibatis.sqlmap.engine.mapping.result.BasicResultMap.
getNestedSelectMappingValue(BasicResultMap.java:411) at
com.ibatis.sqlmap.engine.mapping.result.BasicResultMap.getResults(BasicResultMap
.java:300) at
com.ibatis.sqlmap.engine.execution.SqlExecutor.handleResults(SqlExecutor.java:
363) at
com.ibatis.sqlmap.engine.execution.SqlExecutor.executeQuery(SqlExecutor.java:184
) ...


Cheers,

- stuart


Re: ResultMap composite key problem

Posted by Clinton Begin <cl...@gmail.com>.
That parsing happens in BasicResultMap.

http://svn.apache.org/repos/asf/incubator/ibatis/trunk/java/mapper/mapper2/src/com/ibatis/sqlmap/engine/mapping/result/BasicResultMap.java

There are 3 prepareXxxxxxxParameter methods. One for Primitives, one for DOM 
and one for Beans. The only one that doesn't support the {name=col} is the 
primitive one. 

Cheers,
Clinton

On 5/19/05, Stuart Piltch <st...@gradientblue.com> wrote:
> 
> Clinton Begin <clinton.begin <at> gmail.com <http://gmail.com>> writes:
> 
> > That is terribly strange. We have a unit test confirming proper 
> parsing....I
> wonder if the space is giving you trouble?
> > Ours looks like this:
> > <result property="favouriteLineItem"
> > column="{orderId=ORD_ID,lineId=ORD_FAVOURITE_LINE}"
> > select="getSpecificLineItem"/>
> > Try removing the space.
> > Clinton
> >
> 
> Hi Clinton,
> 
> I tried removing the space. Same message.
> 
> I also brought my older project (that used this syntax) into my current 
> dev
> environment and updated the iBatis jars. No errors. So, the problem isn't 
> with
> iBatis 2.1.0 or with my Mac/Eclipse/Tomcat setup.
> 
> If you can let me know what iBatis class file is reponsible for this 
> parsing, I
> can put some breakpoints in there and see what's going on.
> 
> In the meantime, I'll start removing unrelated jars and classes until it 
> works
> and let you know what I find out.
> 
> 
> Thanks,
> 
> - stuart
> 
> 
>

Re: ResultMap composite key problem

Posted by Stuart Piltch <st...@gradientblue.com>.
Clinton Begin <clinton.begin <at> gmail.com> writes:

> That is terribly strange.  We have a unit test confirming proper parsing....I
wonder if the space is giving you trouble?
> Ours looks like this:
>     <result property="favouriteLineItem"
>       column="{orderId=ORD_ID,lineId=ORD_FAVOURITE_LINE}"
>       select="getSpecificLineItem"/>
> Try removing the space.
> Clinton
> 

Hi Clinton,

I tried removing the space. Same message.

I also brought my older project (that used this syntax) into my current dev
environment and updated the iBatis jars. No errors. So, the problem isn't with
iBatis 2.1.0 or with my Mac/Eclipse/Tomcat setup.

If you can let me know what iBatis class file is reponsible for this parsing, I
can put some breakpoints in there and see what's going on.

In the meantime, I'll start removing unrelated jars and classes until it works
and let you know what I find out. 


Thanks,

 - stuart



Re: ResultMap composite key problem - SOLVED

Posted by Clinton Begin <cl...@gmail.com>.
Hmmm..I suppose we could have implemented a better error check there....feel 
free to put in an "Improvement" in JIRA.

Clinton

On 5/19/05, Stuart Piltch <st...@gradientblue.com> wrote:
> 
> Of course it was something simple.
> 
> After ripping apart my project until it was just one set of bare bones 
> jars
> and classes and still seeing the error, I restored from cvs, cursed the 
> computer
> and made some coffee. After a few sips away from the computer, I realized 
> what
> happened. A quick trip to my desk, followed by one tap (ok, slam) of the 
> delete
> key confirmed it.
> 
> This part was correct as we thought it should be:
> 
> <result property="categories" column="{testId=test_id, 
> asmtId=assessment_id}"
> select="getCompetencyTypes" />
> 
> But, the corresponding select statement looked like this:
> 
> <select id="getCompetencyTypes" parameterClass="int"
> resultMap="competencyTypeResult">
> 
> Removing parameterClass="int" made the problem go away.
> 
> Cheers,
> 
> - stuart
> 
>

Re: ResultMap composite key problem - SOLVED

Posted by Stuart Piltch <st...@gradientblue.com>.
Of course it was something simple.

After ripping apart my project until it was just one set of bare bones jars
and classes and still seeing the error, I restored from cvs, cursed the computer
and made some coffee. After a few sips away from the computer, I realized what
happened. A quick trip to my desk, followed by one tap (ok, slam) of the delete
key confirmed it.

This part was correct as we thought it should be:

<result property="categories" column="{testId=test_id, asmtId=assessment_id}"
select="getCompetencyTypes" />

But, the corresponding select statement looked like this:

<select id="getCompetencyTypes" parameterClass="int"
resultMap="competencyTypeResult">

Removing parameterClass="int" made the problem go away.

Cheers,

 - stuart


Re: ResultMap composite key problem

Posted by Clinton Begin <cl...@gmail.com>.
That is terribly strange. We have a unit test confirming proper parsing....I 
wonder if the space is giving you trouble?

Ours looks like this:

<result property="favouriteLineItem"
column="{orderId=ORD_ID,lineId=ORD_FAVOURITE_LINE}"
select="getSpecificLineItem"/>

Try removing the space.

Clinton

On 5/18/05, Stuart Piltch <st...@gradientblue.com> wrote:
> 
> Hi there,
> 
> I recently added some resultMaps with composite keys as described in the
> documentation: 
> http://ibatisnet.sourceforge.net/DevGuide/ar01s03.html#d0e1064
> 
> I've done this successfully in iBatis before in other projects, but now I 
> keep
> getting a jdbc "Column not found" error (see below for some of the stack 
> trace).
> I'm using the new iBatis 2.1.0, but I've also tried the past few releases 
> as
> well. I've been trying to figure out what is different about this project 
> than
> the previous ones (which are still working fine).
> 
> Before I start copying and pasting large sections of the xml file, I 
> thought I'd
> start with asking if anyone has seen this error and knows what's causing 
> it. If
> it would help, I can start posting sections of the xml.
> 
> I'm using Mac OS X (10.3.9), Tomcat 5.0.29, MySQL 4.1.7, and iBatis 2.1.0. 
> I've
> tried it with lazy loading enabled and disabled and I've tried using a 
> single
> named key (eg column="{testId=test_id}") with the same results. It looks 
> like
> the {...} isn't being parsed by iBatis before being handed off to jdbc.
> 
> The single line that's causing problems is:
> 
> <result property="categories" column="{testId=test_id, 
> asmtId=assessment_id}"
> select="getCompetencyTypes" />
> 
> The error I get is: java.sql.SQLException: Column '{testId=test_id,
> asmtId=assessment_id}' not found. at
> com.mysql.jdbc.ResultSet.findColumn(ResultSet.java:2317) at
> com.mysql.jdbc.ResultSet.getInt(ResultSet.java:1287) at
> org.apache.commons.dbcp.DelegatingResultSet.getInt(
> DelegatingResultSet.java:236)
> at sun.reflect.GeneratedMethodAccessor150.invoke(Unknown Source) at
> sun.reflect.DelegatingMethodAccessorImpl.invoke
> (DelegatingMethodAccessorImpl.
> java:25) at java.lang.reflect.Method.invoke(Method.java:324) at
> com.ibatis.common.jdbc.logging.ResultSetLogProxy.invoke(
> ResultSetLogProxy.java:
> 47) at $Proxy7.getInt(Unknown Source) at
> com.ibatis.sqlmap.engine.type.IntegerTypeHandler.getResult
> (IntegerTypeHandler.
> java:35) at
> com.ibatis.sqlmap.engine.mapping.result.BasicResultMap.
> preparePrimitiveParameterObject(BasicResultMap.java:457) at
> com.ibatis.sqlmap.engine.mapping.result.BasicResultMap.
> getNestedSelectMappingValue(BasicResultMap.java:411) at
> com.ibatis.sqlmap.engine.mapping.result.BasicResultMap.getResults
> (BasicResultMap
> .java:300) at
> com.ibatis.sqlmap.engine.execution.SqlExecutor.handleResults(
> SqlExecutor.java:
> 363) at
> com.ibatis.sqlmap.engine.execution.SqlExecutor.executeQuery(
> SqlExecutor.java:184
> ) ...
> 
> 
> Cheers,
> 
> - stuart
> 
>