ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ole Trenner <ole.tren...@gmx.de>
Subject appending to collection properties
Date Wed, 22 Aug 2007 08:10:20 GMT

I understand iBatis doesn't set collection properties of java beans in
batch, but rather calls the property's getter and then adds to the
returned collection (documentation page 38: "iBATIS will repeatedly call
the get method to access the property, and then call the property's
add() method as it is processing the result set.")

That's why I tried to add to the same collection-type property of a bean
from multiple subqueries like so:

my bean:

public class Article {
    private List<ILabelled> children;
    public Article() {
        this.children = new ArrayList<ILabelled>();
    public List<ILabelled> getChildren() {
        return children;
    public void setChildren(List<ILabelled> children) {
        this.children = children;

my sql map:

<resultMap class="Article" groupBy="id" id="ArticleResult">
    <result column="id" property="children"
    <result column="id" property="children"
    <result column="id" property="children"

Each query returns objects that implement my child interface. Each one
of them by itself works perfectly. But calling all three of them as
shown above always clears the children list before adding to it.

Am I missing something? Is there an explicit way to tell iBatis to
append to my collection property?

Thanks for your help.

View raw message