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 Nathan Maves <Na...@Sun.COM> on 2005/01/25 23:36:06 UTC

Problems with implicit HashMap result mapping

Here is our sqlmap query

<select id="getShipped" resultClass="java.util.HashMap">
         select al1.parts__t as part, SUM(al1.qty_despatched) as shipped
         from despatch AL1, despatch_header AL2
         where AL1.despatch_note__T = al2.despatch_note__T and
         trunc(AL2.despatch_date,'MON') = 
add_months(trunc(sysdate,'MON'),-1)
         AND AL1.request_orig in ('BRR','CM')
         group by al1.parts__t
  </select>


And the logs....

DEBUG 01-25 13:32:39 Created connection 23667197. 
(SimpleDataSource.java:480)
DEBUG 01-25 13:32:39 {conn-100000} Connection  
(ConnectionLogProxy.java:24)
DEBUG 01-25 13:32:39 {pstm-100001} PreparedStatement: select 
al1.parts__t as part,  SUM(al1.qty_despatched) as shipped
from despatch AL1, despatch_header AL2 where AL1.despatch_note__T = 
al2.despatch_note__T and trunc(AL2.despatch_date,'MON') = 
add_months(trunc(sysdate,'MON'),-1) AND AL1.request_orig in 
('BRR','CM') group by al1.parts__t (PreparedStatementLogProxy.java:30)
DEBUG 01-25 13:32:39 {pstm-100001} Parameters: [] 
(PreparedStatementLogProxy.java:31)
DEBUG 01-25 13:32:39 {pstm-100001} Types: [] 
(PreparedStatementLogProxy.java:32)
DEBUG 01-25 13:36:20 {rset-100002} ResultSet  
(ResultSetLogProxy.java:25)
DEBUG 01-25 13:36:21 {rset-100002} Header: [, PART] 
(ResultSetLogProxy.java:45)
DEBUG 01-25 13:36:21 {rset-100002} Result: [100-6889, 44] 
(ResultSetLogProxy.java:49)
DEBUG 01-25 13:36:21 {rset-100002} Result: [100-7192, 1] 
(ResultSetLogProxy.java:49)
DEBUG 01-25 13:36:21 {rset-100002} Result: [100-7270, 7] 
(ResultSetLogProxy.java:49)

Why is the first field null in the Header of the ResultSet?  "PART" 
should be the first element in the header.

Nathan


Re: Problems with implicit HashMap result mapping

Posted by Admin <ma...@friendVU.com>.
Map does not gurante order, if that is your question.

.V

Nathan Maves wrote:

> Here is our sqlmap query
>
> <select id="getShipped" resultClass="java.util.HashMap">
>         select al1.parts__t as part, SUM(al1.qty_despatched) as shipped
>         from despatch AL1, despatch_header AL2
>         where AL1.despatch_note__T = al2.despatch_note__T and
>         trunc(AL2.despatch_date,'MON') = 
> add_months(trunc(sysdate,'MON'),-1)
>         AND AL1.request_orig in ('BRR','CM')
>         group by al1.parts__t
>  </select>
>
>
> And the logs....
>
> DEBUG 01-25 13:32:39 Created connection 23667197. 
> (SimpleDataSource.java:480)
> DEBUG 01-25 13:32:39 {conn-100000} Connection  
> (ConnectionLogProxy.java:24)
> DEBUG 01-25 13:32:39 {pstm-100001} PreparedStatement: select 
> al1.parts__t as part,  SUM(al1.qty_despatched) as shipped
> from despatch AL1, despatch_header AL2 where AL1.despatch_note__T = 
> al2.despatch_note__T and trunc(AL2.despatch_date,'MON') = 
> add_months(trunc(sysdate,'MON'),-1) AND AL1.request_orig in 
> ('BRR','CM') group by al1.parts__t (PreparedStatementLogProxy.java:30)
> DEBUG 01-25 13:32:39 {pstm-100001} Parameters: [] 
> (PreparedStatementLogProxy.java:31)
> DEBUG 01-25 13:32:39 {pstm-100001} Types: [] 
> (PreparedStatementLogProxy.java:32)
> DEBUG 01-25 13:36:20 {rset-100002} ResultSet  (ResultSetLogProxy.java:25)
> DEBUG 01-25 13:36:21 {rset-100002} Header: [, PART] 
> (ResultSetLogProxy.java:45)
> DEBUG 01-25 13:36:21 {rset-100002} Result: [100-6889, 44] 
> (ResultSetLogProxy.java:49)
> DEBUG 01-25 13:36:21 {rset-100002} Result: [100-7192, 1] 
> (ResultSetLogProxy.java:49)
> DEBUG 01-25 13:36:21 {rset-100002} Result: [100-7270, 7] 
> (ResultSetLogProxy.java:49)
>
> Why is the first field null in the Header of the ResultSet?  "PART" 
> should be the first element in the header.
>
> Nathan
>
>


Re: Problems with implicit HashMap result mapping

Posted by Clinton Begin <cl...@gmail.com>.
No idea.  But here's the relevant automapping code if you'd like to
try writing the equivalent JDBC query as a test.  It might be a
problem with the driver (SUM causing a problem with label return??)

Cheers,
Clinton

-------------------------------
      List resultMappingList = new ArrayList();
      ResultSetMetaData rsmd = rs.getMetaData();
      for (int i = 0, n = rsmd.getColumnCount(); i < n; i++) {
        String columnName = rsmd.getColumnLabel(i + 1);
        BasicResultMapping resultMapping = new BasicResultMapping();
        resultMapping.setPropertyName(columnName);
        resultMapping.setColumnName(columnName);
        resultMapping.setColumnIndex(i + 1);
        ...
      }
-------------------------------


On Wed, 26 Jan 2005 11:43:16 -0700, Nathan Maves <Na...@sun.com> wrote:
> Anyone get a chance to look at this yet?
> 
> On Jan 25, 2005, at 3:36 PM, Nathan Maves wrote:
> 
> > Here is our sqlmap query
> >
> > <select id="getShipped" resultClass="java.util.HashMap">
> >         select al1.parts__t as part, SUM(al1.qty_despatched) as shipped
> >         from despatch AL1, despatch_header AL2
> >         where AL1.despatch_note__T = al2.despatch_note__T and
> >         trunc(AL2.despatch_date,'MON') =
> > add_months(trunc(sysdate,'MON'),-1)
> >         AND AL1.request_orig in ('BRR','CM')
> >         group by al1.parts__t
> >  </select>
> >
> >
> > And the logs....
> >
> > DEBUG 01-25 13:32:39 Created connection 23667197.
> > (SimpleDataSource.java:480)
> > DEBUG 01-25 13:32:39 {conn-100000} Connection
> > (ConnectionLogProxy.java:24)
> > DEBUG 01-25 13:32:39 {pstm-100001} PreparedStatement: select
> > al1.parts__t as part,  SUM(al1.qty_despatched) as shipped
> > from despatch AL1, despatch_header AL2 where AL1.despatch_note__T =
> > al2.despatch_note__T and trunc(AL2.despatch_date,'MON') =
> > add_months(trunc(sysdate,'MON'),-1) AND AL1.request_orig in
> > ('BRR','CM') group by al1.parts__t (PreparedStatementLogProxy.java:30)
> > DEBUG 01-25 13:32:39 {pstm-100001} Parameters: []
> > (PreparedStatementLogProxy.java:31)
> > DEBUG 01-25 13:32:39 {pstm-100001} Types: []
> > (PreparedStatementLogProxy.java:32)
> > DEBUG 01-25 13:36:20 {rset-100002} ResultSet
> > (ResultSetLogProxy.java:25)
> > DEBUG 01-25 13:36:21 {rset-100002} Header: [, PART]
> > (ResultSetLogProxy.java:45)
> > DEBUG 01-25 13:36:21 {rset-100002} Result: [100-6889, 44]
> > (ResultSetLogProxy.java:49)
> > DEBUG 01-25 13:36:21 {rset-100002} Result: [100-7192, 1]
> > (ResultSetLogProxy.java:49)
> > DEBUG 01-25 13:36:21 {rset-100002} Result: [100-7270, 7]
> > (ResultSetLogProxy.java:49)
> >
> > Why is the first field null in the Header of the ResultSet?  "PART"
> > should be the first element in the header.
> >
> > Nathan
> >
> 
>

Re: Problems with implicit HashMap result mapping

Posted by Nathan Maves <Na...@Sun.COM>.
Anyone get a chance to look at this yet?

On Jan 25, 2005, at 3:36 PM, Nathan Maves wrote:

> Here is our sqlmap query
>
> <select id="getShipped" resultClass="java.util.HashMap">
>         select al1.parts__t as part, SUM(al1.qty_despatched) as shipped
>         from despatch AL1, despatch_header AL2
>         where AL1.despatch_note__T = al2.despatch_note__T and
>         trunc(AL2.despatch_date,'MON') = 
> add_months(trunc(sysdate,'MON'),-1)
>         AND AL1.request_orig in ('BRR','CM')
>         group by al1.parts__t
>  </select>
>
>
> And the logs....
>
> DEBUG 01-25 13:32:39 Created connection 23667197. 
> (SimpleDataSource.java:480)
> DEBUG 01-25 13:32:39 {conn-100000} Connection  
> (ConnectionLogProxy.java:24)
> DEBUG 01-25 13:32:39 {pstm-100001} PreparedStatement: select 
> al1.parts__t as part,  SUM(al1.qty_despatched) as shipped
> from despatch AL1, despatch_header AL2 where AL1.despatch_note__T = 
> al2.despatch_note__T and trunc(AL2.despatch_date,'MON') = 
> add_months(trunc(sysdate,'MON'),-1) AND AL1.request_orig in 
> ('BRR','CM') group by al1.parts__t (PreparedStatementLogProxy.java:30)
> DEBUG 01-25 13:32:39 {pstm-100001} Parameters: [] 
> (PreparedStatementLogProxy.java:31)
> DEBUG 01-25 13:32:39 {pstm-100001} Types: [] 
> (PreparedStatementLogProxy.java:32)
> DEBUG 01-25 13:36:20 {rset-100002} ResultSet  
> (ResultSetLogProxy.java:25)
> DEBUG 01-25 13:36:21 {rset-100002} Header: [, PART] 
> (ResultSetLogProxy.java:45)
> DEBUG 01-25 13:36:21 {rset-100002} Result: [100-6889, 44] 
> (ResultSetLogProxy.java:49)
> DEBUG 01-25 13:36:21 {rset-100002} Result: [100-7192, 1] 
> (ResultSetLogProxy.java:49)
> DEBUG 01-25 13:36:21 {rset-100002} Result: [100-7270, 7] 
> (ResultSetLogProxy.java:49)
>
> Why is the first field null in the Header of the ResultSet?  "PART" 
> should be the first element in the header.
>
> Nathan
>