Java 如何在IBatis的select查询中发送列表?

Java 如何在IBatis的select查询中发送列表?,java,postgresql,ibatis,Java,Postgresql,Ibatis,我正在使用Java1.7、IBatis和postgreSQL 我有一个学生 My函数返回以下结果: 从获取参与方详细信息1102103104中选择* My querys.xml 有什么帮助/建议吗 编辑1:我也尝试了foreach循环,但这并没有让我摆脱这个问题 <select id="get_party_details" parameterType="StudentVO" statementType="PREPARED" resultMap="partyMap">

我正在使用Java1.7、IBatis和postgreSQL

我有一个学生

My函数返回以下结果:

从获取参与方详细信息1102103104中选择*

My querys.xml

有什么帮助/建议吗

编辑1:我也尝试了foreach循环,但这并没有让我摆脱这个问题

<select id="get_party_details" parameterType="StudentVO" statementType="PREPARED" resultMap="partyMap">
        select * from get_party_details(
        <foreach item="friends" index="index" collection="studentFriendNums"
            open="(" separator="," close=")">
            #{friends}
        </foreach>
        )
    </select>
编辑2:我的Ibatis版本是3.2.3

您可以尝试使用iterate标记:


您可以使用foreach:

   <select id="get_party_details" parameterType="StudentVO" 
            statementType="PREPARED" resultMap="partyMap">
                select * from get_party_details
                <foreach item="item" index="index" collection="studentFriendNums"
                    open="(" separator="," close=")">
                #{item}
               </foreach>
    </select>

刚刚看到您的第一次编辑,您不需要在foreach前后打开和关闭括号。参数打开和关闭为您执行此操作。

这是我的错!我只是看过头了!谢谢:使用Iterate给了我一个警告,因为元素类型select的内容必须匹配include | trim | where | set | foreach | choose | if | bind。您使用的是哪个版本的ibatis?您可以发送完整的sqlMap文件吗?org.mybatis mybatis 3.2.3我想mybatis已经取消了对的支持。很抱歉,你可以用标签代替迭代。酷!无论如何,谢谢你的回答!:
StudentId  Student Name     Amt Paid
101          JOHN           428000.00
102          SMITH          275405.00
103          JACKSON        109250.00
104          LOVELESS       63200.00
<select id="get_party_details" parameterType="StudentVO" 
        statementType="PREPARED" resultMap="partyMap">
            select * from get_party_details(#{studentFriendNums})
</select>

    <resultMap type="StudentVO" id="partyMap">
        <result property="studentId"            column="studentid" />
        <result property="studentName"          column="studentname" />
        <result property="amtPaid"              column="amtpaid" />
    </resultMap>
org.apache.ibatis.exceptions.PersistenceException: 
### Error querying database.  Cause: java.lang.IllegalStateException: Type handler was null on parameter mapping for property 'studentFriendNums'.  It was either not specified and/or could not be found for the javaType / jdbcType combination specified.
### Cause: java.lang.IllegalStateException: Type handler was null on parameter mapping for property 'studentFriendNums'.  It was either not specified and/or could not be found for the javaType / jdbcType combination specified.
<select id="get_party_details" parameterType="StudentVO" statementType="PREPARED" resultMap="partyMap">
        select * from get_party_details(
        <foreach item="friends" index="index" collection="studentFriendNums"
            open="(" separator="," close=")">
            #{friends}
        </foreach>
        )
    </select>
org.apache.ibatis.exceptions.PersistenceException: 
### Error querying database.  Cause: org.postgresql.util.PSQLException: ERROR: function get_party_details(record) does not exist
  Hint: No function matches the given name and argument types. You might need to add explicit type casts.
  Position: 15
### The error may exist in com/myblog/queries.xml
### The error may involve com.myblog.StudentDAO.get_party_details-Inline
### The error occurred while setting parameters
### SQL: select * from epc.get_party_details(    (      ?    ,     ?    ,     ?    ,     ?    )    )
### Cause: org.postgresql.util.PSQLException: ERROR: function get_party_details(record) does not exist
  Hint: No function matches the given name and argument types. You might need to add explicit type casts.
  Position: 15
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
  PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
    "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
    <mapper namespace="com.myblog.StudentDTO">

    <select id="get_party_details" parameterType="StudentVO" 
      statementType="PREPARED" resultMap="partyMap">
        select * from get_party_details
     <iterate property="studentFriendNums" conjunction="," open = "(" close = ")">
            #studentFriendNums[]#
     </iterate>
</select>

    <resultMap type="StudentVO" id="partyMap">
        <result property="studentId"            column="studentid" />
        <result property="studentName"          column="studentname" />
        <result property="amtPaid"              column="amtpaid" />
    </resultMap>

</mapper>
<select id="get_party_details" parameterType="StudentVO" 
      statementType="PREPARED" resultMap="partyMap">
        select * from get_party_details
     <iterate property="studentFriendNums" conjunction="," open = "(" close = ")">
            #studentFriendNums[]#
     </iterate>
</select>

<resultMap type="StudentVO" id="partyMap">
    <result property="studentId"            column="studentid" />
    <result property="studentName"          column="studentname" />
    <result property="amtPaid"              column="amtpaid" />
</resultMap>
   <select id="get_party_details" parameterType="StudentVO" 
            statementType="PREPARED" resultMap="partyMap">
                select * from get_party_details
                <foreach item="item" index="index" collection="studentFriendNums"
                    open="(" separator="," close=")">
                #{item}
               </foreach>
    </select>