You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by Anad Fida <am...@gmail.com> on 2005/02/17 11:43:58 UTC

queryForMap from resultMap

I have a Domain Object as following,

public class Account {

    private long accountKey;
    private String accountName;
    private String userName;
    private Date lastUpdateDate;

   // Holds account attribute name - values
    private Map accountAttributes;
 
   // Setters/Getters........
   
}

I have accounts, attributes, account_attributes tables, you know the 
usual relationships. My problem is in order to get the Account and for 
each account, I need to get  its attribute map.

One option is to get all the accounts and then for each account i get 
its attributes as name, value pair using "queryForMap("queryID", 
account.getKey(), "Name", "Value"). But I have around 50, 000 accounts 
and for each account I have to run this extra query so could end up 
running 50, 001 queries.

I was hoping that I could use this queryForMap from accounts resultMap as
<resultMap id="getAccounts">
.....
<result property="accountAttributes" column="accountKey" 
select="getAccountAttributeMap">,
....
</resultMap>

but i want to specify the property for key and property for value, for 
this "getAccountAttributeMap".  I am not sure how to do that from SqlMap?

Any help would be really appreciated.

Amad