Search Results

Search found 1 results on 1 pages for 'shikarn o'.

Page 1/1 | 1 

  • Mybatis nested collection doesn't work correctly with column prefix

    - by Shikarn-O
    I need to set collection for object in another collection using mybatis mappings. It works for me w/o using columnPrefix, but I need it since there are a lot of repeteable columns. <collection property="childs" javaType="ArrayList" ofType="org.example.mybatis.Child" resultMap="ChildMap" columnPrefix="c_"/> </resultMap> <resultMap id="ChildMap" type="org.example.mybatis.Parent"> <id column="Id" jdbcType="VARCHAR" property="id" /> <id column="ParentId" jdbcType="VARCHAR" property="parentId" /> <id column="Name" jdbcType="VARCHAR" property="name" /> <id column="SurName" jdbcType="VARCHAR" property="surName" /> <id column="Age" jdbcType="INTEGER" property="age" /> <collection property="toys" javaType="ArrayList" ofType="org.example.mybatis.Toy" resultMap="ToyMap" columnPrefix="t_"/> </resultMap> <resultMap id="ToyMap" type="org.example.mybatis.Toy"> <id column="Id" jdbcType="VARCHAR" property="id" /> <id column="ChildId" jdbcType="VARCHAR" property="childId" /> <id column="Name" jdbcType="VARCHAR" property="name" /> <id column="Color" jdbcType="VARCHAR" property="color" /> </resultMap> <sql id="Parent_Column_List"> p.Id, p.Name, p.SurName, </sql> <sql id="Child_Column_List"> c.Id as c_Id, c.ParentId as c_ParentId, c.Name as c_Name, c.SurName as c_Surname, c.Age as c_Age, </sql> <sql id="Toy_Column_List"> t.Id as t_Id, t.Name as t_Name, t.Color as t_Color </sql> <select id="getParent" parameterType="java.lang.String" resultMap="ParentMap" > select <include refid="Parent_Column_List"/> <include refid="Child_Column_List" /> <include refid="Toy_Column_List" /> from Parent p left outer join Child c on p.Id = c.ParentId left outer join Toy t on c.Id = t.ChildId where p.id = #{id,jdbcType=VARCHAR} With columnPrefix all works fine, but nested toys collection is empty. Sql query on database works correctly and all toys are joined. May be i missed something or this is bug with mybatis?

    Read the article

1