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 Vamsee Kanakala <va...@gmail.com> on 2005/07/12 09:15:12 UTC

Result map problems...

Hi list,

         I'm facing a strange problem. I have a pretty big query using a 
lot of dynamic sql satements, like this:

http://rafb.net/paste/results/Glxoo380.html

This query basically selects a bunch of columns based on the parameters 
passed. When I run this statement in isolation from a test, it works 
flawlessly. I start up tomcat, and run it from the search page, it works 
once or twice, and the next time it gives a nasty exception like this:

org.springframework.jdbc.UncategorizedSQLException: SqlMapClient operation: encountered SQLException [  
--- The error occurred in com/mafoi/assetregister/dao/Search.xml.  
--- The error occurred while applying a result map.  
--- Check the searchAssets-AutoResultMap.  
--- Check the result mapping for the 'netbalance04' property.  
--- Cause: org.postgresql.util.PSQLException: The column name netbalance04 not found.]; nested exception is com.ibatis.common.jdbc.exception.NestedSQLException:   
--- The error occurred in com/mafoi/assetregister/dao/Search.xml.  
--- The error occurred while applying a result map.  
--- Check the searchAssets-AutoResultMap.  
--- Check the result mapping for the 'netbalance04' property.  
--- Cause: org.postgresql.util.PSQLException: The column name netbalance04 not found.

I know the error is self-explanatory, but the 'netbalance04' should not 
even be selected in this query! Weird thing is that, it works when I run 
the queries independently from a testcase. So I'm guessing that the 
result map, which is a HashMap, is getting cached somewhere and ibatis 
is trying to get the previous query's column names from the current 
result set? It's just guess work, but I'm truly lost. Please help.

Regards,
Vamsee.

Re: Result map problems...

Posted by Vamsee Kanakala <va...@gmail.com>.
Larry Meadors wrote:

>Use t his instead:
>
><select 
>  id="searchAssets" 
>  parameterClass="com.mafoi.assetregister.core.Search"
>  resultClass="java.util.HashMap"
>  remapResults="true">
>
>My guess is that your tests are reloading the sql map each tim, so the
>results are being mapped each time. In your app, that is not the case.
>Adding remapResults="true" will make it so.
>
>Be aware that this could cause a noticable performance degradation. If
>this query needs to run fast, find a way to make it return the same
>results (into a bean) every time you run it.
>  
>
Yes, I have made some changes to the query to return the same results. 
It was only one property so it wasn't too much of a problem. Thanks a lot!


Regards,
Vamsee.






Re: Result map problems...

Posted by Larry Meadors <la...@gmail.com>.
Use t his instead:

<select 
  id="searchAssets" 
  parameterClass="com.mafoi.assetregister.core.Search"
  resultClass="java.util.HashMap"
  remapResults="true">

My guess is that your tests are reloading the sql map each tim, so the
results are being mapped each time. In your app, that is not the case.
Adding remapResults="true" will make it so.

Be aware that this could cause a noticable performance degradation. If
this query needs to run fast, find a way to make it return the same
results (into a bean) every time you run it.

Larry


On 7/12/05, Vamsee Kanakala <va...@gmail.com> wrote:
> Hi list,
> 
>          I'm facing a strange problem. I have a pretty big query using a
> lot of dynamic sql satements, like this:
> 
> http://rafb.net/paste/results/Glxoo380.html
> 
> This query basically selects a bunch of columns based on the parameters
> passed. When I run this statement in isolation from a test, it works
> flawlessly. I start up tomcat, and run it from the search page, it works
> once or twice, and the next time it gives a nasty exception like this:
> 
> org.springframework.jdbc.UncategorizedSQLException: SqlMapClient operation: encountered SQLException [
> --- The error occurred in com/mafoi/assetregister/dao/Search.xml.
> --- The error occurred while applying a result map.
> --- Check the searchAssets-AutoResultMap.
> --- Check the result mapping for the 'netbalance04' property.
> --- Cause: org.postgresql.util.PSQLException: The column name netbalance04 not found.]; nested exception is com.ibatis.common.jdbc.exception.NestedSQLException:
> --- The error occurred in com/mafoi/assetregister/dao/Search.xml.
> --- The error occurred while applying a result map.
> --- Check the searchAssets-AutoResultMap.
> --- Check the result mapping for the 'netbalance04' property.
> --- Cause: org.postgresql.util.PSQLException: The column name netbalance04 not found.
> 
> I know the error is self-explanatory, but the 'netbalance04' should not
> even be selected in this query! Weird thing is that, it works when I run
> the queries independently from a testcase. So I'm guessing that the
> result map, which is a HashMap, is getting cached somewhere and ibatis
> is trying to get the previous query's column names from the current
> result set? It's just guess work, but I'm truly lost. Please help.
> 
> Regards,
> Vamsee.
>

RE: Result map problems...

Posted by Meindert <me...@pastelebusiness.com>.
Bit afraid to answer because I'm also quite new to this.
It sounds right to me that it can't do the auto-result map to the existing
class property if you are not selecting the matching column.


MEINDERT HOVING
Developer, Pastel Payroll
 
Direct:
+27 (21) 680 9015
Main:
+27 (21) 680 9000
Fax:
+27 (21) 680 9090
meindert@pastelebusiness.com
www.pastel.co.za
 
9 out of 10 accountants recommend PASTEL Accounting

-----Original Message-----
From: Vamsee Kanakala [mailto:vamlists@gmail.com] 
Sent: 12 July 2005 09:15 AM
To: user-java@ibatis.apache.org
Subject: Result map problems...

Hi list,

         I'm facing a strange problem. I have a pretty big query using a 
lot of dynamic sql satements, like this:

http://rafb.net/paste/results/Glxoo380.html

This query basically selects a bunch of columns based on the parameters 
passed. When I run this statement in isolation from a test, it works 
flawlessly. I start up tomcat, and run it from the search page, it works 
once or twice, and the next time it gives a nasty exception like this:

org.springframework.jdbc.UncategorizedSQLException: SqlMapClient operation:
encountered SQLException [  
--- The error occurred in com/mafoi/assetregister/dao/Search.xml.  
--- The error occurred while applying a result map.  
--- Check the searchAssets-AutoResultMap.  
--- Check the result mapping for the 'netbalance04' property.  
--- Cause: org.postgresql.util.PSQLException: The column name netbalance04
not found.]; nested exception is
com.ibatis.common.jdbc.exception.NestedSQLException:   
--- The error occurred in com/mafoi/assetregister/dao/Search.xml.  
--- The error occurred while applying a result map.  
--- Check the searchAssets-AutoResultMap.  
--- Check the result mapping for the 'netbalance04' property.  
--- Cause: org.postgresql.util.PSQLException: The column name netbalance04
not found.

I know the error is self-explanatory, but the 'netbalance04' should not 
even be selected in this query! Weird thing is that, it works when I run 
the queries independently from a testcase. So I'm guessing that the 
result map, which is a HashMap, is getting cached somewhere and ibatis 
is trying to get the previous query's column names from the current 
result set? It's just guess work, but I'm truly lost. Please help.

Regards,
Vamsee.

-- 
No virus found in this incoming message.
Checked by AVG Anti-Virus.
Version: 7.0.323 / Virus Database: 267.8.12/46 - Release Date: 11/07/2005
 

-- 
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.323 / Virus Database: 267.8.12/46 - Release Date: 11/07/2005