ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From J R <power_o...@yahoo.com>
Subject Re: Multiple resultMap per connection?
Date Mon, 24 Mar 2008 19:08:47 GMT

Thanks Clinton! But I am not sure how to disable lazy loading in this
scenario, resultClass for getProductList() is not a bean defined in
application context. Forgive me but I am new to spring.

Also, not sure why you said calling methods outside of transaction scope?
Should it not be same transaction scope?



Clinton Begin wrote:
> 
> I believe Spring uses setUserConnection() to pass the connection in.  When
> that is the case, if the lazy loaded properties (such as getProductList)
> are
> called from within the same transaction, they should use the same user
> connection that was passed in.  But if you wait to call those methods
> outside of the transaction scope, then it will use whatever datasource is
> in
> the configuration by default.
> 
> Try disabling lazy loading, just to see if it solves your problem. If it
> does, at least we'll have it nailed down.  Otherwise it could be an odd
> behaviour due to the way Spring uses iBATIS, or a bug in iBATIS.
> 
> Clinton
> 
> On Thu, Mar 20, 2008 at 7:00 PM, J R <power_of_s@yahoo.com> wrote:
> 
>>
>> Anyone? Please help..let me know if I am not clear enough or asking very
>> trivial question.
>>
>>
>>
>> J R wrote:
>> >
>> > I am new to iBatis and having trouble with multiple resultMaps. I have
>> one
>> > resultMap which has properties which are populated by making another
>> > select call. I am extending
>> > org.springframework.orm.ibatis.support.SqlMapClientDaoSupport and in
>> DAO
>> > class I have call as below-
>> >
>> > getSqlMapClientTemplate().queryForList("getCategoryInfo", null);
>> >
>> > Also other requirement is to connect to 2 different databases before
>> SQL
>> > is executed. So database source selection is done using some custom
>> code
>> > and dao has correct database source reference.
>> >
>> > Problem I am seeing is that when getProductList or getAttributeList
>> select
>> > is called, another database connection is made to default database
>> source,
>> > whereas I was expecting it to use same database source as part of the
>> dao.
>> >
>> > Probably I am missing something here which is causing iBatis to make
>> new
>> > connection everytime. But if I add method to DAO like this it uses the
>> > selected datasource.
>> >
>> > getSqlMapClientTemplate().queryForList("getProductList", 10);
>> >
>> > Can anyone help me with this?
>> >
>> > <resultMap id="category" class="Category">
>> >     <result property="cid" column="id" />
>> >     <result property="cname" column="name" />
>> >     <result property="listProduct" column="{key=cid}"
>> > select="getProductList"/>
>> >     <result propertly="listAttribute" column="{key=cid}"
>> > select="getAttributeList"/>
>> > </resultMap>
>> >
>> > <select id="getCategoryInfo" resultMap="category" >
>> >       select id, name
>> >         from categories
>> > </select>
>> >
>> > <resultMap id="product" class="Product">
>> >       <result property="pid" column="pid" />
>> >       <result property="pname" column="pname" />
>> > </resultMap>
>> >
>> > <select id="getProductList" resultMap="product" >
>> >       select pid, pname
>> >         from products
>> >         where categoryid = #key#
>> > </select>
>> >
>> > <resultMap id="attribute" class="Attribute">
>> >       <result property="aid" column="aid" />
>> >       <result property="aname" column="aname" />
>> > </resultMap>
>> >
>> > <select id="getAttributeList" resultMap="attribute" >
>> >       select aid, aname
>> >         from attribute
>> >         where categoryid = #key#
>> > </select>
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Multiple-resultMap-per-connection--tp16136325p16192135.html
>> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
>>
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/Multiple-resultMap-per-connection--tp16136325p16258708.html
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.


Mime
View raw message