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 "Rao, Satish" <sa...@fmr.com> on 2005/10/26 15:58:03 UTC

cacheModel question

Does cacheModel only work with resultClass and resultMap?

Currently I have the following entry in the sqlMap

	  <cacheModel id="cacheFullname" type="OSCACHE">
	  </cacheModel>

	<parameterMap id="some-param" class="SomeParams" >
		<parameter property="someId" mode="IN"
jdbcType="VARCHAR" javaType="java.lang.String"/>
		<parameter property="someRS" jdbcType="ORACLECURSOR"
javaType="java.sql.ResultSet" mode="OUT"/>
	</parameterMap>

	<procedure id="someProcedure" parameterMap="some-param"
cacheModel="cacheFullname">
		{call PROC_NAME(?,?)}
	</procedure>

The stored procedure uses the OUT parameter to fetch the Oracle cursor
and I have CustomTypeHandler to map the Oracle Cursor to a ResultSet.
The cacheModel doesn't work in this case.

Has anyone tried using cacheModel with the above scenario?

Thanks.


Re: cacheModel question

Posted by Alessandro Berbenni <ab...@wellnet.it>.
 Isn't it possible to use multiple result set support (resultMap="resultMap1,
resultMap2" or resultClass="resultClass1, resultClass2") to map ootput
parameter (Ref Cursors) the same way I have done with the first procedure
that return only one output parameter?
 Or is there a chance to extend the iBatis framework to do that?

Ciao,
Alessandro

>Output parameter results are currently not cached. So the best way to deal
>with it is to simply cache it yourself, perhaps in your DAO layer.
>
>
>Cheers,
>Clinton
>
>
>
>
>
>On 9/20/06, aberbenni@wellnet.it <ab...@wellnet.it> wrote:
>>
>> Hi, I have cahced an Oracle Ref Cursor returned by a procedure in this
>> way, with iBatis 2.2.0 build 638.
>>
>>     <cacheModel id="rs-cache" type="MEMORY">
>>         <flushInterval hours="6" />
>>         <property name="reference-type" value="SOFT" />
>>     </cacheModel>
>>
>>     <!-- Single ResultSet Stored Procedure -->
>>
>>     <parameterMap id="single-rs" class="map">
>>         <parameter property="idPortaf" javaType="java.lang.Integer"
>> mode="IN"/>
>>         <parameter property="startPerfDate" jdbcType="DATE" javaType="
>> java.util.Date" mode="IN"/>
>>         <parameter property="endDate" jdbcType="TIMESTAMP" javaType="
>> java.util.Date" mode="IN"/>
>>
>>         <parameter property="output1" jdbcType="ORACLECURSOR" javaType="
>> java.sql.ResultSet" mode="OUT"/>
>>     </parameterMap>
>>
>>     <procedure id="GetSingleEmpRs" parameterMap="single-rs" resultClass="
>> java.util.HashMap" cacheModel="rs-cache" >
>>          {call PKG_FOR_JSP_PERF_ATTRIBUTION.risultatojspPa_1(?,?,?,?)}
>>     </procedure>
>>
>> How can I do it with a procedure that return multiple Oracle Ref Cursors?
>>
>> I have tried this but it is not working:
>>
>>     <!-- Multiple ResultSet Stored Procedure -->
>>
>>     <resultMap id="rc1-map" class="java.util.HashMap">
>>         <result property="data" column="DATA" />
>>     </resultMap>
>>
>>     <resultMap id="rc2-map" class="java.util.HashMap">
>>         <result property="classeDesc2" column="CLASSE_DESC_2" />
>>         <result property="internalWeight" column="INTERNAL_WEIGHT" />
>>     </resultMap>
>>
>>     <parameterMap id="multiple-rs" class="map">
>>         <parameter property="level" jdbcType="VARCHAR" javaType="
>> java.lang.String" mode="IN"/>
>>         <parameter property="type" jdbcType="VARCHAR" javaType="
>> java.lang.String" mode="IN"/>
>>         <parameter property="endDate" jdbcType="DATE" javaType="
>> java.util.Date" mode="IN"/>
>>         <parameter property="perimetro" jdbcType="INTEGER" javaType="
>> java.lang.Integer" mode="IN"/>
>>
>>         <parameter property="output1" jdbcType="ORACLECURSOR" javaType="
>> java.sql.ResultSet" mode="OUT" resultMap="rc1-map"/>
>>         <parameter property="output2" jdbcType="ORACLECURSOR" javaType="
>> java.sql.ResultSet" mode="OUT" resultMap="rc2-map"/>
>>
>>     </parameterMap>
>>
>>     <procedure id="GetMultipleEmpRs" parameterMap="multiple-rs"
>> cacheModel="rs-cache">
>>         {call
>> PKG_ASSET_ALLOCATION.PRINT_POSTITION_KEEPING_JSP(?,?,?,?,?,?)}
>>     </procedure>
>>
>> Thanks,
>> Alessandro
>>
>> Clinton Begin wrote:
>> >
>> > Correct. A cache model will only work with results, not with output
>> params
>> > (because you passed the object in), and certainly not with Oracle
>> cursors
>> > (because they are live connections to the DB).
>> >
>> > Cheers,
>> > Clinton
>> >
>> > On 10/26/05, Rao, Satish <sa...@fmr.com> wrote:
>> >>
>> >>
>> >> Does cacheModel only work with resultClass and resultMap?
>> >>
>> >> Currently I have the following entry in the sqlMap
>> >>
>> >>  <cacheModel id="cacheFullname" type="OSCACHE">
>> >>  </cacheModel>
>> >>
>> >> <parameterMap id="some-param" class="SomeParams" >
>> >> <parameter property="someId" mode="IN" jdbcType="VARCHAR" javaType="
>> >> java.lang.String"/>
>> >> <parameter property="someRS" jdbcType="ORACLECURSOR" javaType="
>> >> java.sql.ResultSet" mode="OUT"/>
>> >> </parameterMap>
>> >>
>> >> <procedure id="someProcedure" parameterMap="some-param"
>> >> cacheModel="cacheFullname">
>> >> {call PROC_NAME(?,?)}
>> >> </procedure>
>> >>
>> >> The stored procedure uses the OUT parameter to fetch the Oracle cursor
>> >> and
>> >> I have CustomTypeHandler to map the Oracle Cursor to a ResultSet.
>> >>
>> >> The cacheModel doesn't work in this case.
>> >>
>> >> Has anyone tried using cacheModel with the above scenario?
>> >>
>> >> Thanks.
-- 
View this message in context: http://www.nabble.com/cacheModel-question-tf452929.html#a6422736
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.


Re: cacheModel question

Posted by Clinton Begin <cl...@gmail.com>.
Correct. A cache model will only work with results, not with output params
(because you passed the object in), and certainly not with Oracle cursors
(because they are live connections to the DB).

Cheers,
Clinton

On 10/26/05, Rao, Satish <sa...@fmr.com> wrote:
>
>
> Does cacheModel only work with resultClass and resultMap?
>
> Currently I have the following entry in the sqlMap
>
>  <cacheModel id="cacheFullname" type="OSCACHE">
>  </cacheModel>
>
> <parameterMap id="some-param" class="SomeParams" >
> <parameter property="someId" mode="IN" jdbcType="VARCHAR" javaType="
> java.lang.String"/>
> <parameter property="someRS" jdbcType="ORACLECURSOR" javaType="
> java.sql.ResultSet" mode="OUT"/>
> </parameterMap>
>
> <procedure id="someProcedure" parameterMap="some-param"
> cacheModel="cacheFullname">
> {call PROC_NAME(?,?)}
> </procedure>
>
> The stored procedure uses the OUT parameter to fetch the Oracle cursor and
> I have CustomTypeHandler to map the Oracle Cursor to a ResultSet.
>
> The cacheModel doesn't work in this case.
>
> Has anyone tried using cacheModel with the above scenario?
>
> Thanks.
>