ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jeff Butler" <jeffgbut...@gmail.com>
Subject Re: Exception "XMLType mapping only supported for Oracle RDBMS"
Date Wed, 30 Apr 2008 13:49:54 GMT
This is the way it works.  If debugging is on, you'll get the proxy.  If
not, you'll get the actual Oracle result set.  Either way, with this code
you are always getting to what you want - the oracle result set.  If there
was a problem, the cast would fail.

I don't know why you are getting null for the document - but the proxy
unwind is working as it should.

Jeff Butler

On Wed, Apr 30, 2008 at 7:06 AM, <Jasmin_Mehta@nexweb.org> wrote:

>
> I did change the code according to what you have suggested in your reply
> below. The code now is:
>
>        public Object getResult(ResultGetter getter) throws SQLException
>        {
>          logger.info("Entered getResult(ResultGetter getter)");
>          Object xmlDocument = null;
>          ResultSet realResultSet = getter.getResultSet();
>          if (Proxy.isProxyClass(realResultSet.getClass()))      / / this
> condition is becoming false always, so its getting actual ResultSet
>          {
>             InvocationHandler ih = Proxy.
> getInvocationHandler(realResultSet);
>             if (ih instanceof ResultSetLogProxy)
>             {
>                realResultSet = ((ResultSetLogProxy) ih).getRs();
>             }
>             else
>             {
>                logger.error("Some non-iBATIS ResultSet Proxy");
>             }
>          }
>             OracleResultSet ors = (OracleResultSet) realResultSet;
>             OPAQUE opaqueValue = null;
>             if (getter.getColumnName() != null)
>             {
>                opaqueValue = ors.getOPAQUE(getter.getColumnName());
>             }
>             else
>             {
>                opaqueValue = ors.getOPAQUE(getter.getColumnIndex());
>             }
>             if (opaqueValue != null)
>             {
>                XMLType xmlResult = XMLType.createXML(opaqueValue);
>                xmlDocument = xmlResult.getDOM();
>             }
>             else
>             {
>                xmlDocument = null;
>             }
>          return xmlDocument;
>        }
>
>
> when i pring realResultSet.getClass() it giving me valueoracle.jdbc.driver.OracleResultSetImpl,
> and that makes Proxy.isProxyClass(realResultSet.getClass()) condition
> false.
> Eventually xmlDocument is remaining null. It was happening before also
> with old code with having ERROR / INFO log level.
>
> What possibly could be wrong?
>
> Thanks
> Jasmin
>
>
>
>
>   *"Jeff Butler" <jeffgbutler@gmail.com>*
>
> 04/29/2008 03:38 PM
>    Please respond to
> user-java@ibatis.apache.org
>
>    To
> user-java@ibatis.apache.org  cc
>   Subject
> Re: Exception "XMLType mapping only supported for Oracle RDBMS"
>
>
>
>
> You made it so that it will only work if DEBUG is enabled.  This will work
> in all circumstances:
>
> (see *
> http://opensource.atlassian.com/confluence/oss/pages/viewpage.action?pageId=15597591
> *<http://opensource.atlassian.com/confluence/oss/pages/viewpage.action?pageId=15597591>
> )
>
> public Object getResult(ResultGetter getter) throws SQLException {
>  logger.info("Entered getResult(ResultGetter getter)");
>  Object xmlDocument = null;
>  ResultSet realResultSet = getter.getResultSet();
>
>  if (Proxy.isProxyClass(realResultSet.getClass())) {
>    InvocationHandler ih = Proxy. getInvocationHandler(realResultSet);
>    if (ih instanceof ResultSetLogProxy) {
>      realResultSet = ((ResultSetLogProxy) ih).getRs();
>     } else {
>       logger.error("Some non-iBATIS ResultSet Proxy");
>    }
>   }
>   OracleResultSet ors = (OracleResultSet) realResultSet;
>  OPAQUE opaqueValue = null;
>  if (getter.getColumnName() != null)  {
>    opaqueValue = ors.getOPAQUE(getter.getColumnName());
>  } else {
>    opaqueValue = ors.getOPAQUE(getter.getColumnIndex());
>   }
>
>   if (opaqueValue != null) {
>    XMLType xmlResult = XMLType.createXML(opaqueValue);
>    xmlDocument = xmlResult.getDOM();
>  } else {
>    xmlDocument = null;
>  }
>   return xmlDocument;
> }
>
> Jeff Butler
>
>
>
> On Tue, Apr 29, 2008 at 2:19 PM, <*Jasmin_Mehta@nexweb.org*<Jasmin_Mehta@nexweb.org>>
> wrote:
>
> Jeff,
>
> Here is my code for ResultSet TypeHandlerCallback.
>
>
>       public Object getResult(ResultGetter getter) throws SQLException
>      {
>          logger.info("Entered getResult(ResultGetter getter)");
>         Object xmlDocument = null;
>          ResultSet rs = getter.getResultSet();
>
>          if (Proxy.isProxyClass(rs.getClass()))
>         {
>           InvocationHandler ih = Proxy. getInvocationHandler(rs);
>           if (ih instanceof ResultSetLogProxy)
>           {
>               ResultSet realResultSet = ((ResultSetLogProxy) ih).getRs();
>                OracleResultSet ors = (OracleResultSet) realResultSet;
>               OPAQUE opaqueValue = null;
>               if (getter.getColumnName() != null)
>               {
>                   opaqueValue = ors.getOPAQUE(getter.getColumnName());
>               }
>               else
>               {
>                   opaqueValue = ors.getOPAQUE(getter.getColumnIndex());
>                }
>              if (opaqueValue != null)
>              {
>                  XMLType xmlResult = XMLType.createXML(opaqueValue);
>                   xmlDocument = xmlResult.getDOM();
>              }
>              else
>              {
>                  xmlDocument = null;
>              }
>           }
>         }
>         else
>         {
>             logger.error("ResultSet class is not Proxy class");
>             xmlDocument = null;
>         }
>         return xmlDocument;
>       }
>
>
> I have ibatis-2.3.0.677.jar and I have tried with both log4j-1.2.8.jar and
> log4j-1.2.13.jar as well. But as long as I keep the log level to DEBUG it
> works fine. If I change it to either INFO or ERROR,  I am getting error on
> reading resultset for XML datatype
>
> [29 Apr 2008 11:58:33] INFO  [XMLTypeHandlerCallback] Entered
> getResult(ResultGetter getter)
>     [exec] [29 Apr 2008 11:58:33] ERROR [XMLTypeHandlerCallback] ResultSet
> class is not Proxy class
>     [exec] [29 Apr 2008 11:58:33] INFO  [XMLTypeHandlerCallback] Entered
> getResult(ResultGetter getter)
>     [exec] [29 Apr 2008 11:58:33] ERROR [XMLTypeHandlerCallback] ResultSet
> class is not Proxy class
>     [exec] java.lang.NullPointerException
>     [exec]         at
> org.jdom.input.DOMBuilder.buildTree(DOMBuilder.java:166)
>     [exec]         at
> org.jdom.input.DOMBuilder.build(DOMBuilder.java:135):
>
>
> How do I fix it for log level ERROR or INFO?
>
> Thanks
> Jasmin
>
>
>
>   *"Jeff Butler" <**jeffgbutler@gmail.com* <jeffgbutler@gmail.com>*>*
>
> 12/26/2007 10:30 PM
>
>
>   Please respond to*
> **user-java@ibatis.apache.org* <user-java@ibatis.apache.org>
>
>    To
> *user-java@ibatis.apache.org* <user-java@ibatis.apache.org>  cc
>   Subject
> Re: Exception "XMLType mapping only supported for Oracle RDBMS"
>
>
>
>
>
> Here's how to get the real resultset from a the proxied class:
>
>
> *public* Object getResult(ResultGetter getter) *throws* SQLException {
> ResultSet rs = getter.getResultSet();*
> if* (Proxy.*isProxyClass*(rs.getClass())) {
>   InvocationHandler ih = Proxy. *getInvocationHandler*(rs);*
>   if* (ih *instanceof* ResultSetLogProxy) {
>     ResultSet realResultSet = ((ResultSetLogProxy) ih).getRs();
>     // do something here...
>   }
> }
> }
>
> It's ugly - but it works.
>
> Jeff Butler
> On Dec 26, 2007 11:37 AM, <*Jasmin_Mehta@nexweb.org*<Jasmin_Mehta@nexweb.org>>
> wrote:
>
> Jeff,
>
> I did read your posting at *
> http://www.mail-archive.com/user-java@ibatis.apache.org/msg06898.html*<http://www.mail-archive.com/user-java@ibatis.apache.org/msg06898.html>
already before sending this question. I could not understand how/where do I
> modify the code to consider proxy class.
>
> My getOpaqueValue() displays *ResultSet class is: $Proxy2, *not
> ResultSetLogProxy.
>
> The program DOES WORK if I turn off logging.
>
> I tried something like this:
>
> public Object getResult(ResultGetter getter) throws SQLException {
>   //    if (getter.getResultSet() instanceof OracleResultSet) {
>           OPAQUE opaqueValue = getOpaqueValue(getter);
>           if (opaqueValue != null) {
>               XMLType xmlResult = XMLType.createXML (opaqueValue);
>               return xmlResult.getDOM();
>           } else {
>               return null;
>           }
>    //   } else {
>     //      throw new UnsupportedOperationException("XMLType mapping only
> supported for Oracle RDBMS");
>     //  }
>   }
>
>
>   private OPAQUE getOpaqueValue(ResultGetter getter) throws SQLException {
>
>
>
>         java.sql.ResultSet rs = getter.getResultSet();
>         System.out.println("ResultSet class is: " + rs.getClass());
>   //       ResultSetLogProxy rsProx =  (ResultSetLogProxy)rs;
>         OracleResultSet ors =
> (OracleResultSet)ResultSetLogProxy.newInstance(rs);         //--- *THROWS
> ClassCastException*
>         OPAQUE op = null;
>         if (getter.getColumnName() != null) {
>             op = ors.getOPAQUE(getter.getColumnName());
>         } else {
>             op = ors.getOPAQUE(getter.getColumnIndex());
>         }
>         return op;
>     }
>
>
> Thanks
>
>
>   *"Jeff Butler" <**jeffgbutler@gmail.com* <jeffgbutler@gmail.com>*>*
>
> 12/26/2007 12:24 PM
>   Please respond to *
> **
> **user-java@ibatis.apache.org* <user-java@ibatis.apache.org>
>
>
>   To
> *user-java@ibatis.apache.org* <user-java@ibatis.apache.org>  cc
>   Subject
> Re: Exception "XMLType mapping only supported for Oracle RDBMS"
>
>
>
>
>
>
> The code in the wiki article does not take into account the fact that
> iBATIS logging changes the normal classes to proxy classes.  First thing to
> do is turn off logging to see it will work.  Second thing, the code must be
> modified to account for the proxy class if logging is enabled (add another
> instanceof check for the proxy class, then unwind the embedded "real"
> class).
>
> See here for more information:
> *
> **http://www.mail-archive.com/user-java@ibatis.apache.org/msg06898.html*<http://www.mail-archive.com/user-java@ibatis.apache.org/msg06898.html>
>
> Jeff Butler
>
>
>
> On Dec 26, 2007 10:26 AM, < *Jasmin_Mehta@nexweb.org*<Jasmin_Mehta@nexweb.org>>
> wrote:
>
> I am using code as directed in this url: *
>
> **http://opensource.atlassian.com/confluence/oss/display/IBATIS/XMLTypeHandlerCallback.java
> *<http://opensource.atlassian.com/confluence/oss/display/IBATIS/XMLTypeHandlerCallback.java>
>
> It throw UnsupportedOperationException("XMLType mapping only supported for
> Oracle RDBMS");
>
> I have logger set to DEBUG  mode.
>
> I tried displaying class from ResultSet like :
>
>       java.sql.ResultSet rs = getter.getResultSet();
>       System.out.println("ResultSet class is: " + rs.getClass());
>
> The cosole displays
>
> [20 Dec 2007 15:15:05] DEBUG [PreparedStatement] {pstm-100001} Executing
> Statement:         SELECT OTM, SEQUENCE, MESSAGETYPE, MESSAGEID, STATUS,
> PROCESSED_TIME, CREATED     FROM OTM_XML
> [20 Dec 2007 15:15:05] DEBUG [PreparedStatement] {pstm-100001} Parameters:
> []
> [20 Dec 2007 15:15:05] DEBUG [PreparedStatement] {pstm-100001} Types: []
> [20 Dec 2007 15:15:05] DEBUG [ResultSet] {rset-100002} ResultSet *
> ResultSet class is: class $Proxy2 *
>
> I am using JDeveloper *10.1.3.1* <http://10.1.3.1/>
>
> What should I change in my code to make it working?
>
> Thanks
>
> *
> ******************************************************************************
> *
> ATTENTION ATTENTION ATTENTION ATTENTION ATTENTION
> Our domain name is changing.  Please take note of the sender's
> e-Mail address and make changes to your personal address list,
> if needed.  Both domains will continue to work, only for a limited
> time.
>
> ******************************************************************************
> This email and any files transmitted with it are intended solely for
> the use of the individual or agency to whom they are addressed.
> If you have received this email in error please notify the Navy
> Exchange Service Command e-mail administrator. This footnote
> also confirms that this email message has been scanned for the
> presence of computer viruses.
>
> Thank You!            *
>
> ******************************************************************************
> *
>
>

Mime
View raw message