Return-Path: Delivered-To: apmail-ibatis-user-java-archive@www.apache.org Received: (qmail 95963 invoked from network); 17 Sep 2008 00:12:07 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 17 Sep 2008 00:12:07 -0000 Received: (qmail 4591 invoked by uid 500); 17 Sep 2008 00:11:57 -0000 Delivered-To: apmail-ibatis-user-java-archive@ibatis.apache.org Received: (qmail 4574 invoked by uid 500); 17 Sep 2008 00:11:57 -0000 Mailing-List: contact user-java-help@ibatis.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user-java@ibatis.apache.org Delivered-To: mailing list user-java@ibatis.apache.org Received: (qmail 4563 invoked by uid 99); 17 Sep 2008 00:11:57 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 16 Sep 2008 17:11:57 -0700 X-ASF-Spam-Status: No, hits=2.2 required=10.0 tests=HTML_MESSAGE,SPF_PASS,WHOIS_MYPRIVREG X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of fatboysuns@gmail.com designates 66.249.92.175 as permitted sender) Received: from [66.249.92.175] (HELO ug-out-1314.google.com) (66.249.92.175) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 17 Sep 2008 00:10:58 +0000 Received: by ug-out-1314.google.com with SMTP id s2so261343uge.1 for ; Tue, 16 Sep 2008 17:11:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:cc:in-reply-to:mime-version:content-type:references; bh=1I64alRSV2uJ2ppqnQIZ+3BGqgnQgcU0SX5VvMuoTd0=; b=c7H9ZhPysArLqLQCm8maygm4BxwToiT5nPl8YyHb0yqMRiMt+VArqEVTAyWOkoeBfX kwcJh72a2+ZQ9Djaa+Jp5ynYpLyQa2XMyKwauD6KP+dqt/0bVGKU10xYMy0u+FpliuKV xu4KAsjgfgIGD31qwA/n4cIKXzfjgRXqNmsbo= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version :content-type:references; b=uD0ztPLFjA48hEeMvkuTo1tfsTtybE4vJUgOWhX/Hj+Z5EIHsGIWwdRyc1A1z9bxc9 W4L+o4eUc38J+bQCGqKJk+tz+RKiYtfWazXaKThlPpMgnnoGvKTQKlCvbAewiIHMGUXE JNRkna1Dz/q6HNaANnSvynB6txct/lnVB4Cvw= Received: by 10.67.15.15 with SMTP id s15mr435323ugi.28.1221610288936; Tue, 16 Sep 2008 17:11:28 -0700 (PDT) Received: by 10.67.123.10 with HTTP; Tue, 16 Sep 2008 17:11:28 -0700 (PDT) Message-ID: Date: Tue, 16 Sep 2008 17:11:28 -0700 From: "Sundar Sankar" To: "George Marvin" Subject: Re: Caching not working Cc: user-java@ibatis.apache.org In-Reply-To: <8cea82050809161441o2e8dba77vbc911e53e323eabe@mail.gmail.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_1962_11378814.1221610288941" References: <19286237.456031221065696478.JavaMail.nabble@isper.nabble.com> <8cea82050809161441o2e8dba77vbc911e53e323eabe@mail.gmail.com> X-Virus-Checked: Checked by ClamAV on apache.org ------=_Part_1962_11378814.1221610288941 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Thanks! Will try it out and let you know. On Tue, Sep 16, 2008 at 2:41 PM, George Marvin wrote: > Hi Sundar, > I have a much better solution. I was able to successfully subclass > oracle.sql.ARRAY and just add the equals() and hashcode() methods. Here is a > sample of how it looks: > > > package mil.af.dcapes.ddms.vocs; > > /** > * VOCSArray is a sub-class of oracle.sql.ARRAY. It is used to hold > parameters > * and that are used to construct a lookup key in OSCache. VOCSArray was > constructed > * to implement an equals() method and hashcode() method that are used by > OSCache to > * do key lookups of results stored in OSCache. > */ > > import java.sql.Connection; > import java.sql.SQLException; > > import oracle.sql.ARRAY; > import oracle.sql.ArrayDescriptor; > > public class VOCSArray extends ARRAY { > > /** > * > */ > private static final long serialVersionUID = -4640581956617812831L; > > public VOCSArray(ArrayDescriptor arraydescriptor, Connection > connection, Object obj) > throws SQLException { > super(arraydescriptor,connection,obj); > > } > > // Comparison and hashing > > /** > * Compares the specified VOCSArray with this VOCSArray for equality. > Returns > * true if and only if the specified object is also an > VOCSArray, both > * VOCSArrays have the same size, and the oracle.sql.ARRAYs they hold > are

> * > * This implementation first checks if the specified object is this > * VOCSArray. If so, it returns true; if not, it checks if the > * specified object is a VOCSArray. If not, it returns false; > if so, > * it checks if the lengths of both VOCSArrays are the same, if not it > returns > * false, if the lengths are the same it checks to see if the > oracle.sql.ARRAYs > * they extend are equal, if not it returns false else it > returns >true. > * > * @param o the object to be compared for equality with this list. > * > * @return true if the specified object is equal to this list. > */ > public boolean equals(VOCSArray o) { > if (o == this) > return true; > if (!(o instanceof VOCSArray)) > return false; > try { > if (this.length() != o.length()) > return false; > if (!(this.getArray().equals(o.getArray()))) { > return false; > } > } catch (SQLException e) { > // TODO Auto-generated catch block > e.printStackTrace(); > } > return true; > } > > /** > * Returns the hash code value for this list.

> * > * This implementation uses exactly the code that is used to define the > * list hash function in the documentation for the > List.hashCode > * method. > * > * @return the hash code value for this list. > */ > public int hashCode() { > int hashCode=0; > try { > hashCode = 1; > for (int i=1; i < length(); i++) { > hashCode = hashCode*i; > } > } catch (SQLException e) { > // TODO Auto-generated catch block > e.printStackTrace(); > } > return hashCode; > } > > > > > > } > > Then you can specify it as an ARRAY in your SQLMap.xml file as a param and > pass it. The Oracle stored procedure will interpret it correctly and return > a resultset. Since the Array is used for its equals() and hashcode() methods > by OSCache it will work. This is works just fine! > Hope this helps > > > On Wed, Sep 10, 2008 at 2:04 PM, Sundar Sankar wrote: > >> Hey george, >> If I remember right, Some one told me that Stored >> procedure out param caching was not supported By ibatis itself. Can you send >> the code snippet and let the group know what change u did to what class. As >> far I know OJDBC14 is not an open source. If you overrided the methods, how >> did u manage to do it? If it is a change somewhere in the Ibatis Jar, we >> could include it hopefully. >> >> Thanks for the response. I totally appreciate it. It would solve a lot of >> issues in our project if that could be achieved. I am currently using too >> many static variables and am using primitive way of coding. >> >> >> -Sundar >> >> On Wed, Sep 10, 2008 at 9:54 AM, wrote: >> >>> >>> Sundar Sankar wrote: >>> > >>> > Hi, >>> > I tried to cache the data returned by my stored proc and I am >>> > seeing >>> > that the data fetched from the procedure is not cached at all. Am I >>> doing >>> > wrong here. I tried to use OSCache and Memory. Both dont seem to work >>> at >>> > all >>> > for me. >>> > >>> > My configurations are >>> > >>> > >>> > >>> > >>> > >>> > >>> > >>> > >>> > >> > parameterMap="someParam" cacheModel="oscache"> >>> > {? = call someProc} >>> > >>> > >>> > My oscache.properties is fairly simple and has >>> > >>> > cache.memory=true >>> > #cache.capacity=1000 >>> > #cache.algorithm=com.opensymphony.oscache.base.algorithm.UnlimitedCache >>> > cache.use.host.domain.in.key=true >>> > cache.path=c:\\Sundar\\cache >>> > >>> > ################################################### >>> > >>> > My debug statements are >>> > >>> > 2008-06-17 16:49:53,148 DEBUG >>> [com.ibatis.sqlmap.engine.cache.CacheModel] >>> > Cache 'oscache': *cache miss* >>> > 2008-06-17 16:49:53,148 DEBUG [java.sql.Connection] {conn-100019} >>> > Preparing >>> > Call: {? = call someProc} >>> > 2008-06-17 16:49:53,179 DEBUG [java.sql.PreparedStatement] >>> {pstm-100020} >>> > Executing Statement: {? = call someProc} >>> > 2008-06-17 16:49:53,179 DEBUG [java.sql.PreparedStatement] >>> {pstm-100020} >>> > Parameters: [] >>> > 2008-06-17 16:49:53,179 DEBUG [java.sql.PreparedStatement] >>> {pstm-100020} >>> > Types: [] >>> > 2008-06-17 16:49:53,195 DEBUG >>> > [com.ibatis.sqlmap.engine.cache.CacheModel] *Cache >>> > 'oscache': stored object '[]'* >>> > >>> > >>> > Dont know what I am doing wrong. I tried changing the congiguration to >>> > point >>> > to the memory-cache config I have. Still yeilds the same results. Any >>> help >>> > on this is greatly appreciated. >>> > >>> > Regards >>> > Sundar Sankarnarayanan >>> > >>> > >>> Quoted from: >>> http://www.nabble.com/Caching-not-working-tp17957249p17957249.html >>> >>> >>> I ran into the same problem. It was because we were passing in >>> oracle.sql.ARRAYs to our stored procedure. The problem was cause because >>> oracle.sql.ARRAY does not have a hashcode() and an equals() method. I added >>> these two methods and the OsCache with IBATIS works fine. The problem is I >>> really don't want to modify oracle.sql.ARRAY >>> >> >> > ------=_Part_1962_11378814.1221610288941 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline

Thanks! Will try it out and let you know.

On Tue, Sep 16, 2008 at 2:41 PM, George Marvin <georgemarvin0@gmail.com> wrote:
Hi Sundar,
I have a much better solution. I was able to successfully subclass oracle.sql.ARRAY and just add the equals() and hashcode() methods. Here is a sample of how it looks:


package mil.af.dcapes.ddms.vocs;

/**
 * VOCSArray is a sub-class of oracle.sql.ARRAY. It is used to hold parameters
 * and that are used to construct a lookup key in OSCache. VOCSArray was constructed
 * to implement an equals() method and hashcode() method that are used by OSCache to
 * do key lookups of results stored in OSCache.
 */

import java.sql.Connection;
import java.sql.SQLException;

import oracle.sql.ARRAY;
import oracle.sql.ArrayDescriptor;

public class VOCSArray extends ARRAY {
   
    /**
     *
     */
    private static final long serialVersionUID = -4640581956617812831L;

    public VOCSArray(ArrayDescriptor arraydescriptor, Connection connection, Object obj)
    throws SQLException {
        super(arraydescriptor,connection,obj);
       
    }
   
       // Comparison and hashing

    /**
     * Compares the specified VOCSArray with this VOCSArray for equality.  Returns
     * <tt>true</tt> if and only if the specified object is also an VOCSArray, both
     * VOCSArrays have the same size, and the oracle.sql.ARRAYs they hold are <p>
     *
     * This implementation first checks if the specified object is this
     * VOCSArray. If so, it returns <tt>true</tt>; if not, it checks if the
     * specified object is a VOCSArray. If not, it returns <tt>false</tt>; if so,
     * it checks if the lengths of both VOCSArrays are the same, if not it returns
     * <tt>false</tt>, if the lengths are the same it checks to see if the oracle.sql.ARRAYs
     * they extend are equal, if not it returns <tt>false</tt> else it returns <tt>>true</tt>.
     *
     * @param o the object to be compared for equality with this list.
     *
     * @return <tt>true</tt> if the specified object is equal to this list.
     */
    public boolean equals(VOCSArray o) {
    if (o == this)
        return true;
    if (!(o instanceof VOCSArray))
        return false;
    try {
        if (this.length() != o.length())
            return false;
        if (!(this.getArray().equals(o.getArray()))) {
            return false;
        }
    } catch (SQLException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return true;
    }

    /**
     * Returns the hash code value for this list. <p>
     *
     * This implementation uses exactly the code that is used to define the
     * list hash function in the documentation for the <tt>List.hashCode</tt>
     * method.
     *
     * @return the hash code value for this list.
     */
    public int hashCode() {
    int hashCode=0;
    try {
        hashCode = 1;
        for (int i=1; i < length(); i++) {
            hashCode = hashCode*i;
        }
    } catch (SQLException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return hashCode;
    }





}

Then you can specify it as an ARRAY in your SQLMap.xml file as a param and pass it. The Oracle stored procedure will interpret it correctly and return a resultset. Since the Array is used for its equals() and hashcode() methods by OSCache it will work. This is works just fine!
Hope this helps


On Wed, Sep 10, 2008 at 2:04 PM, Sundar Sankar <fatboysuns@gmail.com> wrote:
Hey george,
                 If I remember right, Some one told me that Stored procedure out param caching was not supported By ibatis itself. Can you send the code snippet and let the group know what change u did to what class. As far I know OJDBC14 is not an open source. If you overrided the methods, how did u manage to do it? If it is a change somewhere in the Ibatis Jar, we could include it hopefully.

Thanks for the response. I totally appreciate it. It would solve a lot of issues in our project if that could be achieved. I am currently using too many static variables and am using primitive way of coding.


-Sundar

On Wed, Sep 10, 2008 at 9:54 AM, <georgemarvin0@gmail.com> wrote:

Sundar Sankar wrote:
>
> Hi,
>        I tried to cache the data returned by my stored proc and I am
> seeing
> that the data fetched from the procedure is not cached at all. Am I doing
> wrong here. I tried to use OSCache and Memory. Both dont seem to work at
> all
> for me.
>
> My configurations are
>
> <cacheModel id="oscache" type="OSCACHE">
>             <flushInterval hours="24"/>
>         </cacheModel>
>         <cacheModel id="memory-cache" type="MEMORY">
>             <flushInterval hours="24"/>
>         </cacheModel>
>
> <procedure id="something"
>         parameterMap="someParam" cacheModel="oscache">
>         {? = call someProc}
>     </procedure>
>
> My oscache.properties is fairly simple and has
>
> cache.memory=true
> #cache.capacity=1000
> #cache.algorithm=com.opensymphony.oscache.base.algorithm.UnlimitedCache
> cache.use.host.domain.in.key=true
> cache.path=c:\\Sundar\\cache
>
> ###################################################
>
> My debug statements are
>
> 2008-06-17 16:49:53,148 DEBUG [com.ibatis.sqlmap.engine.cache.CacheModel]
> Cache 'oscache': *cache miss*
> 2008-06-17 16:49:53,148 DEBUG [java.sql.Connection] {conn-100019}
> Preparing
> Call: {? = call someProc}
> 2008-06-17 16:49:53,179 DEBUG [java.sql.PreparedStatement] {pstm-100020}
> Executing Statement: {? = call someProc}
> 2008-06-17 16:49:53,179 DEBUG [java.sql.PreparedStatement] {pstm-100020}
> Parameters: []
> 2008-06-17 16:49:53,179 DEBUG [java.sql.PreparedStatement] {pstm-100020}
> Types: []
> 2008-06-17 16:49:53,195 DEBUG
> [com.ibatis.sqlmap.engine.cache.CacheModel] *Cache
> 'oscache': stored object '[]'*
>
>
> Dont know what I am doing wrong. I tried changing the congiguration to
> point
> to the memory-cache config I have. Still yeilds the same results. Any help
> on this is greatly appreciated.
>
> Regards
> Sundar Sankarnarayanan
>
>
Quoted from:
http://www.nabble.com/Caching-not-working-tp17957249p17957249.html


I ran into the same problem. It was because we were passing in oracle.sql.ARRAYs to our stored procedure. The problem was cause because oracle.sql.ARRAY does not have a hashcode() and an equals() method. I added these two methods and the OsCache with IBATIS works fine. The problem is I really don't want to modify oracle.sql.ARRAY



------=_Part_1962_11378814.1221610288941--