Hello,

   after several minutes of trying I make up how to use @Many annotation -
there is no example of it neither in documentation nor in iBatis test suite:

@Select(
            "select product.*, product.id as idProduct, productGroup.name as
groupName, productGroup.groupType" +
            " from product inner join productGroup on idGroup =
productGroup.id" +
            " where id = #{id}"
    )
    @Results({
        @Result(property = "id", id = true),
        @Result(property = "name"),
        @Result(property = "group.id", column = "idGroup", id = true),
        @Result(property = "group.name", column = "groupName"),
        @Result(property = "group.groupType", column = "groupType"),
        @Result(property = "tags", column = "idProduct",
                many = @Many(select =
"cz.novoj.ibatis.ProductMapper.getTagsForProduct")
        )
    })
    Product getFullProductByIdAnnotation(int id);

    @Select("select tag.id, tag.name" +
             " from tag inner join productTag on productTag.idTag = tag.id"
+
             " where productTag.idProduct = #{value}"
    )
    List<Tag> getTagsForProduct(int idProduct);

   I deduce, that I am not able to define collection loading in annotations
other way than by lazy select (N + 1 problem?!). I don't see how to use it
for single joined SQLs. Am I right?

Cheers Jan

-- 
--------------------------------------------------------------
Ing. Jan Novotný
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
http://blog.novoj.net
Myšlenky dne otce Fura
--------------------------------------------------------------

Reply via email to