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 "D. Richter" <dr...@gmx.de> on 2006/04/04 14:04:07 UTC

Complex Property is null

Hi,

I have two classes:

public class EMail
{
  private String id;
  private String subject;
  private Person from;
  ...
}

public class Person
{
  private String id;
  private String name;
  ...
}

and a configfile

...
<sqlMap namespace="EMail">

<resultMap id="getEMailByIdResult" class="EMail">
 <result property="id" column="id"/>
 <result property="subject" column="subject"/>
 <result property="from" column="from" select="getPersonById"/>
</resultMap>

<resultMap id="getPersonByIdResult" class="Person">
 <result property="id" column="id"/>
 <result property="name" column="name"/>
</resultMap>

<select id="getEMailById" resultMap="getEMailByIdResult"
parameterClass="int">
 SELECT id, subject, from
 FROM email
 WHERE id = #id#
</select>
	
<select id="getPersonById" resultMap="getPersonByIdResult"
parameterClass="int">
 SELECT id, name
 FROM person
 WHERE id = #id#
</select>
	
</sqlMap>

When I call queryForObject, I get the following logs:

Created connection 17627854.
{conn-100000} Connection
{pstm-100001} PreparedStatement: SELECT id, subject, from FROM email WHERE
id = ? 
{pstm-100001} Parameters: [1]
{pstm-100001} Types: [java.lang.Integer]
{rset-100002} ResultSet
{pstm-100003} PreparedStatement: SELECT id, name FROM person WHERE id = ? 
{pstm-100003} Parameters: [96]
{pstm-100003} Types: [java.lang.Integer]
{rset-100004} ResultSet
{rset-100002} Header: [mata_id, mata_vbetrag, mata_vwbezk, mata_zpkey]
{rset-100002} Result: [1, A_subject, 96]
Returned connection 17627854 to pool.

No error/exception occurs, but the property 'from' in the instance of
'EMail' is still null. Can anyone help me to find the mistake?

Thank you
Dennis

-- 
Analog-/ISDN-Nutzer sparen mit GMX SmartSurfer bis zu 70%!
Kostenlos downloaden: http://www.gmx.net/de/go/smartsurfer

Re: Complex Property is null

Posted by Larry Meadors <lm...@apache.org>.
Very good debugging, and thanks for posting the solution. :-)

Larry


On 4/4/06, D. Richter <dr...@gmx.de> wrote:
> Ok, I found the mistake by myself. It is a type mismatch
> in the Person-Select. The db-type of id ist varchar, so the
> parameterClass must be string. Unfortunately no error or warning
> points to the mistake.
>
> Dennis
>
> > --- Ursprüngliche Nachricht ---
> > Von: "D. Richter" <dr...@gmx.de>
> > An: user-java@ibatis.apache.org
> > Betreff: Complex Property is null
> > Datum: Tue, 4 Apr 2006 14:04:07 +0200 (MEST)
> >
> > Hi,
> >
> > I have two classes:
> >
> > public class EMail
> > {
> >   private String id;
> >   private String subject;
> >   private Person from;
> >   ...
> > }
> >
> > public class Person
> > {
> >   private String id;
> >   private String name;
> >   ...
> > }
> >
> > and a configfile
> >
> > ...
> > <sqlMap namespace="EMail">
> >
> > <resultMap id="getEMailByIdResult" class="EMail">
> >  <result property="id" column="id"/>
> >  <result property="subject" column="subject"/>
> >  <result property="from" column="from" select="getPersonById"/>
> > </resultMap>
> >
> > <resultMap id="getPersonByIdResult" class="Person">
> >  <result property="id" column="id"/>
> >  <result property="name" column="name"/>
> > </resultMap>
> >
> > <select id="getEMailById" resultMap="getEMailByIdResult"
> > parameterClass="int">
> >  SELECT id, subject, from
> >  FROM email
> >  WHERE id = #id#
> > </select>
> >
> > <select id="getPersonById" resultMap="getPersonByIdResult"
> > parameterClass="int">
> >  SELECT id, name
> >  FROM person
> >  WHERE id = #id#
> > </select>
> >
> > </sqlMap>
> >
> > When I call queryForObject, I get the following logs:
> >
> > Created connection 17627854.
> > {conn-100000} Connection
> > {pstm-100001} PreparedStatement: SELECT id, subject, from FROM email WHERE
> > id = ?
> > {pstm-100001} Parameters: [1]
> > {pstm-100001} Types: [java.lang.Integer]
> > {rset-100002} ResultSet
> > {pstm-100003} PreparedStatement: SELECT id, name FROM person WHERE id = ?
> > {pstm-100003} Parameters: [96]
> > {pstm-100003} Types: [java.lang.Integer]
> > {rset-100004} ResultSet
> > {rset-100002} Header: [mata_id, mata_vbetrag, mata_vwbezk, mata_zpkey]
> > {rset-100002} Result: [1, A_subject, 96]
> > Returned connection 17627854 to pool.
> >
> > No error/exception occurs, but the property 'from' in the instance of
> > 'EMail' is still null. Can anyone help me to find the mistake?
> >
> > Thank you
> > Dennis
> >
> > --
> > Analog-/ISDN-Nutzer sparen mit GMX SmartSurfer bis zu 70%!
> > Kostenlos downloaden: http://www.gmx.net/de/go/smartsurfer
> >
>
> --
> "Feel free" - 10 GB Mailbox, 100 FreeSMS/Monat ...
> Jetzt GMX TopMail testen: http://www.gmx.net/de/go/topmail
>

Re: Complex Property is null

Posted by "D. Richter" <dr...@gmx.de>.
Ok, I found the mistake by myself. It is a type mismatch
in the Person-Select. The db-type of id ist varchar, so the
parameterClass must be string. Unfortunately no error or warning
points to the mistake.

Dennis

> --- Ursprüngliche Nachricht ---
> Von: "D. Richter" <dr...@gmx.de>
> An: user-java@ibatis.apache.org
> Betreff: Complex Property is null
> Datum: Tue, 4 Apr 2006 14:04:07 +0200 (MEST)
> 
> Hi,
> 
> I have two classes:
> 
> public class EMail
> {
>   private String id;
>   private String subject;
>   private Person from;
>   ...
> }
> 
> public class Person
> {
>   private String id;
>   private String name;
>   ...
> }
> 
> and a configfile
> 
> ...
> <sqlMap namespace="EMail">
> 
> <resultMap id="getEMailByIdResult" class="EMail">
>  <result property="id" column="id"/>
>  <result property="subject" column="subject"/>
>  <result property="from" column="from" select="getPersonById"/>
> </resultMap>
> 
> <resultMap id="getPersonByIdResult" class="Person">
>  <result property="id" column="id"/>
>  <result property="name" column="name"/>
> </resultMap>
> 
> <select id="getEMailById" resultMap="getEMailByIdResult"
> parameterClass="int">
>  SELECT id, subject, from
>  FROM email
>  WHERE id = #id#
> </select>
> 	
> <select id="getPersonById" resultMap="getPersonByIdResult"
> parameterClass="int">
>  SELECT id, name
>  FROM person
>  WHERE id = #id#
> </select>
> 	
> </sqlMap>
> 
> When I call queryForObject, I get the following logs:
> 
> Created connection 17627854.
> {conn-100000} Connection
> {pstm-100001} PreparedStatement: SELECT id, subject, from FROM email WHERE
> id = ? 
> {pstm-100001} Parameters: [1]
> {pstm-100001} Types: [java.lang.Integer]
> {rset-100002} ResultSet
> {pstm-100003} PreparedStatement: SELECT id, name FROM person WHERE id = ? 
> {pstm-100003} Parameters: [96]
> {pstm-100003} Types: [java.lang.Integer]
> {rset-100004} ResultSet
> {rset-100002} Header: [mata_id, mata_vbetrag, mata_vwbezk, mata_zpkey]
> {rset-100002} Result: [1, A_subject, 96]
> Returned connection 17627854 to pool.
> 
> No error/exception occurs, but the property 'from' in the instance of
> 'EMail' is still null. Can anyone help me to find the mistake?
> 
> Thank you
> Dennis
> 
> -- 
> Analog-/ISDN-Nutzer sparen mit GMX SmartSurfer bis zu 70%!
> Kostenlos downloaden: http://www.gmx.net/de/go/smartsurfer
> 

-- 
"Feel free" - 10 GB Mailbox, 100 FreeSMS/Monat ...
Jetzt GMX TopMail testen: http://www.gmx.net/de/go/topmail