Oracle SYS.XMLTYPE

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Oracle SYS.XMLTYPE

Brian Hayward
I'm unable to map the Oracle SYS.XMLType into a Java String.
The field ends up null, with no exceptions reported.

There was another thread where someone suggested setting jdbcType =
"VARCHAR", I tried but it's still mapped as null.

When using jdbcType=CLOB or LONGVARCHAR, I get:Invalid Column Type:
getCLOB not implemented for class
oracle.jdbc.driver.T4CNamedTypAccessor.

Has anyone else been able to select into a String from a column that
is the Oracle XML Type?

Any help is appreciated,

mybatis 3.0.2, Oracle 11g.

Thanks,
Brian
Reply | Threaded
Open this post in threaded view
|

Re: Oracle SYS.XMLTYPE

Brian Hayward
I  found the answer to my problem.  For others who follow:
Since MyBatis doesn't know how to handle the SYS.XMLTYPE, you can let
Oracle convert it to CLOB for you:

SELECT T.XMLDOC.getClobVal() as DOC from MY_TABLE T;

I had initially tried to_clob(XMLDOC) but I got exceptions when an XML
tag contained data larger than 4000.

Thanks,
Brian


On Tue, Oct 26, 2010 at 11:00 PM, Brian Hayward <[hidden email]> wrote:

> I'm unable to map the Oracle SYS.XMLType into a Java String.
> The field ends up null, with no exceptions reported.
>
> There was another thread where someone suggested setting jdbcType =
> "VARCHAR", I tried but it's still mapped as null.
>
> When using jdbcType=CLOB or LONGVARCHAR, I get:Invalid Column Type:
> getCLOB not implemented for class
> oracle.jdbc.driver.T4CNamedTypAccessor.
>
> Has anyone else been able to select into a String from a column that
> is the Oracle XML Type?
>
> Any help is appreciated,
>
> mybatis 3.0.2, Oracle 11g.
>
> Thanks,
> Brian
Reply | Threaded
Open this post in threaded view
|

Re: Oracle SYS.XMLTYPE

Giovanni Cuccu
If you are interested in the topic I published some posts on my blog
about xmltype mapping.

http://www.jpadbf.org/2010/02/jdbc-xmltype-and-ora-01461/
http://www.jpadbf.org/2010/04/jdbc-xmltype-and-ora-01461-revisited-part-i/
http://www.jpadbf.org/2010/05/oracle-xmltype-and-ibatis-2-x-without-ora-1461/

Hope it help understand how to manage xmltype  and how to deal with
different oracle jdbc driver versions

Giovanni

--------------------------------------------------------------------
"You don't know the power of dark side" - Darth Vader



On Wed, Oct 27, 2010 at 6:47 AM, Brian Hayward <[hidden email]> wrote:

> I  found the answer to my problem.  For others who follow:
> Since MyBatis doesn't know how to handle the SYS.XMLTYPE, you can let
> Oracle convert it to CLOB for you:
>
> SELECT T.XMLDOC.getClobVal() as DOC from MY_TABLE T;
>
> I had initially tried to_clob(XMLDOC) but I got exceptions when an XML
> tag contained data larger than 4000.
>
> Thanks,
> Brian
>
>
> On Tue, Oct 26, 2010 at 11:00 PM, Brian Hayward <[hidden email]> wrote:
>> I'm unable to map the Oracle SYS.XMLType into a Java String.
>> The field ends up null, with no exceptions reported.
>>
>> There was another thread where someone suggested setting jdbcType =
>> "VARCHAR", I tried but it's still mapped as null.
>>
>> When using jdbcType=CLOB or LONGVARCHAR, I get:Invalid Column Type:
>> getCLOB not implemented for class
>> oracle.jdbc.driver.T4CNamedTypAccessor.
>>
>> Has anyone else been able to select into a String from a column that
>> is the Oracle XML Type?
>>
>> Any help is appreciated,
>>
>> mybatis 3.0.2, Oracle 11g.
>>
>> Thanks,
>> Brian
>