ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tony Qian" <daqiqi...@aol.com>
Subject Re: groupBy issue
Date Fri, 13 Jan 2006 14:57:01 GMT
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <title></title>
</head>
<body>
<font face="Arial,sans-serif"><font size="2">Mark,<br>
<br>
The brand_id is the first field in the result which is 2. last field is
description.<br>
<br>
</font></font><font color="#0000ff" face="Arial,sans-serif" size="2">DEBUG
01-12 17:33:37 {rset-100002} Header: [brand_id, parameter_value,
parameter_id, parameter_name, description]&nbsp;
(JakartaCommonsLoggingImpl.java:23)<br>
DEBUG 01-12 17:33:37 {rset-100002} Result: [2, 78, 3, auth_challenge,
Used by the client for hashing the user's password in preparation for
web authentication.]
<br>
</font><font color="#0000ff" face="Arial,sans-serif" size="2">DEBUG
01-12 17:33:37 {rset-100002} Result: [2, </font><font  face="Arial,sans-serif" size="2"><a
 title="http://walker.office.compuserve.c/" href="http://xx.office.c/"  target="_blank" onclick="return
top.js.OpenExtLink(window,event,this)">
http://xx.office.c/</a></font><font color="#0000ff"  face="Arial,sans-serif"
size="2">om:9580/session/session_start.jsp, 4,
auth_url, Page where the client should direct the user to start the
web-based authentication process.]&nbsp; <br>
DEBUG 01-12 17:33:37 {rset-100002} Result: [2, 78, 5, ces_heartbeat,
How often the client should monitor the connection in minutes]&nbsp;
(JakartaCommonsLoggingImpl.<br>
</font><font face="Arial,sans-serif" size="2"><a title="java:23">java:23</a></font><font
 color="#0000ff" face="Arial,sans-serif" size="2">
)</font><br>
<font face="Arial,sans-serif"><font size="2"><br>
according to my test result, groupBy actually worked. I issued
sqlMap.queryForObject( "</font></font><font face="Arial,sans-serif"  size="2">selectCommonSession",
"2"). It returned a single</font><font  face="Arial,sans-serif"><font size="2">
Object and brandId was set to
2 and parameters is null. Otherwise, I would get a list with three
objects.<br>
<br>
It's very odd.<br>
<br>
Tony<br>
<br>
&nbsp;<br>
<span type="cite">Mark Bennett wrote on 1/13/2006, 9:18 AM:</span>
</font></font>
<p><font face="Arial,sans-serif" size="2"></font></p>
<blockquote type="cite"  style="border-left: thin solid blue; padding-left: 10px; margin-left:
0pt;"><font  face="Arial,sans-serif" size="2">Tony,<br>
  <br>
You are grouping by brand_id, but the data that comes back does not
look like an id.&nbsp; If I'm looking at it right, the value for the first
row brand_id is "</font><font color="#0000ff" face="Arial,sans-serif"  size="2">Used
by th<br>
e client for hashing the user's password in preparation for web
authentication.".&nbsp;
  </font><font face="Arial,sans-serif" size="2"><span> They are all
unique and therefore will be no grouping.<br>
  <br>
Mark<br>
  </span><br>
  </font>
  <div><font face="Arial,sans-serif" size="2"><span class="gmail_quote">On
1/12/06, <b class="gmail_sendername"><a href="mailto:DaqiQian2@aol.com">DaqiQian2@aol.com</a>
  </b> &lt;<a href="mailto:DaqiQian2@aol.com">DaqiQian2@aol.com</a>&gt;
wrote:</span></font>
  <blockquote class="gmail_quote"  style="border-left: 1px solid rgb(204, 204, 204); margin:
0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><font  face="Arial,sans-serif" size="2"></font>
    <div><font face="Arial,sans-serif" size="2">Mark and Tim,</font></div>
    <font face="Arial,sans-serif" size="2"></font>
    <div><font face="Arial,sans-serif" size="2">&nbsp;</font></div>
    <font face="Arial,sans-serif" size="2"></font>
    <div><font face="Arial,sans-serif" size="2">Thanks your help.&nbsp; I
checked all of your suggestions. It still doesn't work. </font></div>
    <font face="Arial,sans-serif" size="2"></font>
    <div><font face="Arial,sans-serif" size="2">&nbsp;</font></div>
    <font face="Arial,sans-serif" size="2"></font>
    <div><font face="Arial,sans-serif" size="2">Here are the info for
scaled down version.</font></div>
    <font face="Arial,sans-serif" size="2"></font>
    <div><font face="Arial,sans-serif" size="2">&nbsp;</font></div>
    <font face="Arial,sans-serif" size="2"></font>
    <div><font color="#ff0080" face="Arial,sans-serif" size="2">class
info</font></div>
    <font face="Arial,sans-serif" size="2"></font>
    <div><font face="Arial,sans-serif" size="2">&nbsp;</font></div>
    <font face="Arial,sans-serif" size="2"></font>
    <div><font face="Arial,sans-serif" size="2">public class
SessionCommon <br>
{<br>
&nbsp;&nbsp; &nbsp;private List parameters;<br>
&nbsp;&nbsp; &nbsp;private String brandId;<br>
    <br>
&nbsp;&nbsp; &nbsp;public void setBrandId(String id){<br>
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;this.brandId = id;<br>
&nbsp;&nbsp; &nbsp;}<br>
&nbsp;&nbsp; &nbsp;public String getBrandId(){
    <br>
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;return this.brandId;<br>
&nbsp;&nbsp; &nbsp;}<br>
&nbsp;&nbsp; &nbsp;public void setParameters(List elements){<br>
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;this.parameters = parameters;<br>
&nbsp;&nbsp; &nbsp;}<br>
&nbsp;&nbsp; &nbsp;public List getParameters(){<br>
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;return this.parameters;<br>
&nbsp;&nbsp; &nbsp;}<br>
&nbsp;&nbsp; &nbsp;public SessionCommon(){<br>
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;brandId = null;<br>
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;parameters = null;<br>
&nbsp;&nbsp; &nbsp;}<br>
}<br>
    <br>
public class SessionElement <br>
{<br>
&nbsp;&nbsp;&nbsp; private Parameter parameter;<br>
&nbsp;&nbsp;&nbsp; private String value;<br>
    <br>
&nbsp;&nbsp;&nbsp; public void setParameter(Parameter parameter){
    <br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; this.parameter = parameter;<br>
&nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp; public Parameter getParameter(){<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return this.parameter;<br>
&nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp; public void setValue(String value){<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; this.value = value;<br>
&nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp; public String getValue(){
    <br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return this.value;<br>
&nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp; <br>
&nbsp;&nbsp;&nbsp; public String toString() {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return ReflectionToStringBuilder.toString(this);<br>
&nbsp;&nbsp;&nbsp; }</font></div>
    <font face="Arial,sans-serif" size="2"></font>
    <div><font face="Arial,sans-serif" size="2">&nbsp;</font></div>
    <font face="Arial,sans-serif" size="2"></font>
    <div><font face="Arial,sans-serif" size="2">&nbsp;&nbsp;&nbsp;
public
SessionElement(){</font></div>
    <font face="Arial,sans-serif" size="2"></font>
    <div><font face="Arial,sans-serif" size="2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
parameter =
new Parameter();</font></div>
    <font face="Arial,sans-serif" size="2"></font>
    <div><font face="Arial,sans-serif" size="2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
value = null;</font></div>
    <font face="Arial,sans-serif" size="2"></font>
    <div><font face="Arial,sans-serif" size="2">}</font></div>
    <font face="Arial,sans-serif" size="2"></font>
    <div><font face="Arial,sans-serif" size="2"><br>
public class Parameter <br>
{<br>
&nbsp;&nbsp;&nbsp; private String parameterName;<br>
&nbsp;&nbsp;&nbsp; private String parameterId;<br>
&nbsp;&nbsp;&nbsp; private String description;<br>
    <br>
&nbsp;&nbsp;&nbsp; public void setParameterName(String name){<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; this.parameterName = name;<br>
&nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp; public String getParameterName(){<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return this.parameterName;<br>
&nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp; public void setParameterId(String id){<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; this.parameterId = id;<br>
&nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp; public String getParameterId(){
    <br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return this.parameterId;<br>
&nbsp;&nbsp;&nbsp; }<br>
    <br>
&nbsp;&nbsp;&nbsp; public void setDescription(String id){<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; this.description = id;<br>
&nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp; public String getDescription(){<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return this.description;<br>
&nbsp;&nbsp;&nbsp; }
    <br>
    <br>
&nbsp;&nbsp;&nbsp; public Parameter(){<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; //empty<br>
&nbsp;&nbsp;&nbsp; }<br>
    <br>
&nbsp;&nbsp;&nbsp; public String toString() {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return ReflectionToStringBuilder.toString(this);<br>
&nbsp;&nbsp;&nbsp; }<br>
    </font></div>
    <font face="Arial,sans-serif" size="2"></font>
    <div><font color="#ff0080" face="Arial,sans-serif" size="2">mapping
info</font></div>
    <font face="Arial,sans-serif" size="2"></font>
    <div><font face="Arial,sans-serif" size="2"><br>
&lt;sqlMap namespace="CommonSession"&gt;<br>
    <br>
&nbsp; &lt;typeAlias alias="sessionCommon"
type="com.netscape.isp.quickstart.SessionCommon"/&gt;<br>
&nbsp; &lt;typeAlias alias="element" type="
com.netscape.isp.quickstart.SessionElement"/&gt;<br>
&nbsp; <br>
&nbsp; &lt;resultMap id="elementMap" class="element"&gt;<br>
&nbsp; &lt;result property="value" column="parameter_value"/&gt;<br>
&nbsp; &lt;result property="parameter.parameterId" column="parameter_id"/&gt;<br>
&nbsp; &lt;result property="parameter.parameterName"
column="parameter_name"/&gt;<br>
&nbsp; &lt;result property="
parameter.description" column="description"/&gt;<br>
&nbsp; &lt;/resultMap&gt;<br>
&nbsp; <br>
&nbsp; &lt;resultMap id="selectSessionCommon" class="sessionCommon"
groupBy="brandId"&gt;<br>
&nbsp; &lt;result property="brandId" column="brand_id"/&gt;
    <br>
&nbsp; &lt;result property="parameters"
resultMap="CommonSession.elementMap"/&gt;<br>
&nbsp; &lt;/resultMap&gt;<br>
&nbsp; <br>
&nbsp; &lt;select id="selectCommonSession" parameterClass="string"
resultMap="selectSessionCommon"&gt;
    <br>
&nbsp;&nbsp;&nbsp; &nbsp; SELECT distinct <br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; SP.parameter_id,<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; SP.parameter_name,<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; SP.description,<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; SC.parameter_value ,<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; SC.brand_id <br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; FROM SESSION_INFO_COMMON as SC, SESSION_PARAMETER
as SP where
SP.parameter_id=SC.parameter_id and brand_id=#brandId#; <br>
&nbsp; &lt;/select&gt;<br>
&nbsp; <br>
&lt;/sqlMap&gt;<br>
    </font></div>
    <font face="Arial,sans-serif" size="2"></font>
    <div><font color="#ff0080" face="Arial,sans-serif" size="2">log info<br>
    </font><font face="Arial,sans-serif" size="2"><br>
DEBUG 01-12 17:33:37 Created connection 3735543.&nbsp;
(JakartaCommonsLoggingImpl.jav<br>
a:23)<br>
DEBUG 01-12 17:33:37 {conn-100000} Connection&nbsp;
(JakartaCommonsLoggingImpl.java
:2<br>
3)<br>
DEBUG 01-12 17:33:37 {pstm-100001} PreparedStatement:&nbsp;&nbsp;&nbsp;&nbsp;
SELECT
distinct&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; S<br>
P.parameter_id,&nbsp;&nbsp;&nbsp;&nbsp; SP.parameter_name,&nbsp;&nbsp;&nbsp;&nbsp;
SP.description,&nbsp;&nbsp;&nbsp;&nbsp;
SC.parameter_valu<br>
e ,&nbsp;&nbsp;&nbsp;&nbsp; SC.brand_id&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
FROM SESSION_INFO_COMMON as SC,
SESSION_PARAMETER as SP
    <br>
&nbsp;where SP.parameter_id=SC.parameter_id and brand_id=?;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
(JakartaCommonsLoggi<br>
ngImpl.java:23)<br>
DEBUG 01-12 17:33:37 {pstm-100001} Parameters: [2]&nbsp;
(JakartaCommonsLoggingImpl.j<br>
ava:23)<br>
DEBUG 01-12 17:33:37 {pstm-100001} Types: [
java.lang.String]&nbsp; (JakartaCommonsLog<br>
gingImpl.java:23)<br>
DEBUG 01-12 17:33:37 {rset-100002} ResultSet&nbsp;
(JakartaCommonsLoggingImpl.java:23<br>
)<br>
    </font><font color="#0000ff" face="Arial,sans-serif" size="2">DEBUG
01-12 17:33:37 {rset-100002} Header: [brand_id, parameter_value,
parameter
    <br>
_id, parameter_name, description]&nbsp; (JakartaCommonsLoggingImpl.java:23)<br>
DEBUG 01-12 17:33:37 {rset-100002} Result: [2, 78, 3, auth_challenge,
Used by th<br>
e client for hashing the user's password in preparation for web
authentication.]
    <br>
&nbsp; (JakartaCommonsLoggingImpl.java:23)<br>
DEBUG 01-12 17:33:37 {rset-100002} Result: [2, </font><font  face="Arial,sans-serif"
size="2"><a  title="http://walker.office.compuserve.c/" href="http://xx.office.c/" 
target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
http://xx.office.c/</a><br>
    </font><font color="#0000ff" face="Arial,sans-serif" size="2">om:9580/session/session_start.jsp,
4, auth_url, Page where the client should dir<br>
ect the user to start the web-based authentication process.]&nbsp;
(JakartaCommonsLog<br>
gingImpl.java
:23)<br>
DEBUG 01-12 17:33:37 {rset-100002} Result: [2, 78, 5, ces_heartbeat,
How often t<br>
he client should monitor the connection in minutes]&nbsp;
(JakartaCommonsLoggingImpl.<br>
    </font><font face="Arial,sans-serif" size="2"><a title="java:23">java:23</a></font><font
 color="#0000ff" face="Arial,sans-serif" size="2">
)<br>
    </font><font face="Arial,sans-serif" size="2">DEBUG 01-12 17:33:37
Returned connection 3735543 to pool.&nbsp; (JakartaCommonsLoggin<br>
    </font></div>
    <font face="Arial,sans-serif" size="2"></font>
    <div><font face="Arial,sans-serif" size="2">The log info marked
blue told us resultMap got data required to build SessionCommon. The
funny thing is that only this query didn't work. Other queries using
groupBy worked properly. is it possible that this is due to mismatch
of&nbsp;data type of brandId (dataType of &nbsp;brand_id is tinyint in
database)?&nbsp;&nbsp;
    </font></div>
    <font face="Arial,sans-serif" size="2"></font>
    <div><font face="Arial,sans-serif" size="2">&nbsp;</font></div>
    <font face="Arial,sans-serif" size="2"></font>
    <div><font face="Arial,sans-serif" size="2">btw, I'm using latest
version of iBATIS and&nbsp;MySQL 5.0&nbsp;</font></div>
    <font face="Arial,sans-serif" size="2"></font>
    <div><font face="Arial,sans-serif" size="2">&nbsp;</font></div>
    <font face="Arial,sans-serif" size="2"></font>
    <div><font face="Arial,sans-serif" size="2">thanks,</font></div>
    <font face="Arial,sans-serif" size="2"></font>
    <div><font face="Arial,sans-serif" size="2">Tony</font></div>
    <font face="Arial,sans-serif" size="2"></font></blockquote>
  </div>
  <font face="Arial,sans-serif" size="2"><br>
  </font></blockquote>
</body>
</html>


Mime
View raw message