ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Niels Beekman" <n.beek...@wis.nl>
Subject RE: appending to collection properties
Date Wed, 22 Aug 2007 08:42:00 GMT
You would have to create a select that joins all children and returns
them in one shot.


-----Original Message-----
From: Ole Trenner [mailto:ole.trenner@gmx.de] 
Sent: woensdag 22 augustus 2007 10:10
To: user-java@ibatis.apache.org
Subject: appending to collection properties


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