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 Hermit Geek <He...@yahoo.com> on 2010/03/17 00:12:04 UTC

Composite key problems in column attribute (again)

I know this has been addressed before but it's still not working for me.

I'm developing an application pro bono for the local community college. It
was mostly working in Ibatis 2 and then when I migrated to 3, my composite
keys would no longer work. I'm currently in Ibatis 3, beta 10. Below is a
portion of my mapper file. The collection property works as expected with a
single parameter (autoID) and a hard coded second parameter for the
composite key as indicated below in the resultMap.

<resultMap id="dsrcStudentResult"    type="studentData" >
        <id property="autoID"                 column="autoid" />
        <result property="activeSemester"    column="activeSemester"/>
        <result property="studentID"        column="studentID"/>
        <result property="lastName"            column="lastname"/>
        <result property="firstName"        column="firstname"/>
        ...
       
        <collection property="disabilityList" javaType="ArrayList"
ofType="String"
            column="autoID" select="getDisabilityList" />
       
    </resultMap>
   
    
     <select id="getDisabilityList"  resultType="java.lang.String">
        SELECT specificdisabilityfkey
             FROM joinDsrcStudentDisability
             WHERE joinDsrcStudentDisability.dsrcStudentFKey = #{id}
             AND semesterFKey = '20081'
             
     </select>   

    <select id="getStudentByAutoID" parameterType="studentQueryParam"
resultMap="dsrcStudentResult" >
        SELECT *, #{activeSemester} AS activeSemester   
        FROM dsrcStudent
        WHERE dsrcStudent.autoID = #{autoID}
     </select>

I changed the column attribute to accommodate composite keys and substitute
the hard coded semesterFKey parameter with #{semester}

        column="{autoID=id,activeSemester=semester}"

        SELECT specificdisabilityfkey
             FROM joinDsrcStudentDisability
             WHERE joinDsrcStudentDisability.dsrcStudentFKey = #{id}
             AND semesterFKey = #{semester}

When the program executes, I get the following error:

### Error querying database.  Cause:
org.apache.ibatis.reflection.ReflectionException: There is no setter for
property named 'autoID' in 'class java.lang.Object'
### The error may involve dsrcdata.getStudentByAutoID-Inline
### The error occurred while setting parameters

Am I doing something wrong, or should I wait for a later release?
Thanks for the help,
James Templer
-- 
View this message in context: http://old.nabble.com/Composite-key-problems-in-column-attribute-%28again%29-tp27925843p27925843.html
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
For additional commands, e-mail: user-java-help@ibatis.apache.org


Re: Composite key problems in column attribute (again)

Posted by Guy Rouillier <gu...@burntmail.com>.
You haven't specified the parameterType for the nested getDisabilityList 
select statement.  So, iBATIS defaults the best it can to type Object. 
You then try to set two properties on that Object, autoID and semester. 
  Object doesn't have such properties, hence the error message.

Specify an parameterType that has those two properties.

On 3/16/2010 7:12 PM, Hermit Geek wrote:
>
> I know this has been addressed before but it's still not working for me.
>
> I'm developing an application pro bono for the local community college. It
> was mostly working in Ibatis 2 and then when I migrated to 3, my composite
> keys would no longer work. I'm currently in Ibatis 3, beta 10. Below is a
> portion of my mapper file. The collection property works as expected with a
> single parameter (autoID) and a hard coded second parameter for the
> composite key as indicated below in the resultMap.
>
> <resultMap id="dsrcStudentResult"    type="studentData">
>          <id property="autoID"                 column="autoid" />
>          <result property="activeSemester"    column="activeSemester"/>
>          <result property="studentID"        column="studentID"/>
>          <result property="lastName"            column="lastname"/>
>          <result property="firstName"        column="firstname"/>
>          ...
>
>          <collection property="disabilityList" javaType="ArrayList"
> ofType="String"
>              column="autoID" select="getDisabilityList" />
>
>      </resultMap>
>
>
>       <select id="getDisabilityList"  resultType="java.lang.String">
>          SELECT specificdisabilityfkey
>               FROM joinDsrcStudentDisability
>               WHERE joinDsrcStudentDisability.dsrcStudentFKey = #{id}
>               AND semesterFKey = '20081'
>
>       </select>
>
>      <select id="getStudentByAutoID" parameterType="studentQueryParam"
> resultMap="dsrcStudentResult">
>          SELECT *, #{activeSemester} AS activeSemester
>          FROM dsrcStudent
>          WHERE dsrcStudent.autoID = #{autoID}
>       </select>
>
> I changed the column attribute to accommodate composite keys and substitute
> the hard coded semesterFKey parameter with #{semester}
>
>          column="{autoID=id,activeSemester=semester}"
>
>          SELECT specificdisabilityfkey
>               FROM joinDsrcStudentDisability
>               WHERE joinDsrcStudentDisability.dsrcStudentFKey = #{id}
>               AND semesterFKey = #{semester}
>
> When the program executes, I get the following error:
>
> ### Error querying database.  Cause:
> org.apache.ibatis.reflection.ReflectionException: There is no setter for
> property named 'autoID' in 'class java.lang.Object'
> ### The error may involve dsrcdata.getStudentByAutoID-Inline
> ### The error occurred while setting parameters
>
> Am I doing something wrong, or should I wait for a later release?
> Thanks for the help,
> James Templer


-- 
Guy Rouillier

---------------------------------------------------------------------
To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
For additional commands, e-mail: user-java-help@ibatis.apache.org