-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 posts ] 
Author Message
 Post subject: Oracle Longs
PostPosted: Thu Aug 28, 2003 7:05 pm 
Newbie

Joined: Thu Aug 28, 2003 11:49 am
Posts: 15
Location: Calgary, Alberta, Canada
I saw a message regarding this issue in the old Sourceforge forum but I didn't see a resolution. Here is a (partial) hibernate mapping:

Code:
<class name="Column" mutable="false"  table="user_tab_cols">
        <composite-id>
            <key-many-to-one name="table" class="Table" column="table_name"/>           
            <key-property name="name" column="column_name" type="string" length="30" />       
        </composite-id>
       
        <property name="dataType" column="data_type" length="106" not-null="false" type="string"/>
        <property name="length" column="data_length" not-null="true" type="java.lang.Long"/>       
        <property name="precision" column="data_precision" not-null="false" type="java.lang.Long"/>       
        <property name="scale" column="data_scale" not-null="false" type="java.lang.Long"/>
        <property name="nullable" column="nullable" length="1" not-null="false" type="string"/>
        <property name="defaultValue" column="data_default" not-null="false" type="string"/>
        <property name="sequence" column="column_id" not-null="false" type="java.lang.Long"/>
    </class>


that fails when calling it like this:

Code:
Query query = session.createQuery("from Column as c where c.table.name = 'ABC'");
        List columnList = query.list();
        System.out.println(columnList.size());


But works if you do it like this:

Code:
Iterator columns = session.iterate("from Column as c where c.table.name = 'ANALYTES'");
        while (columns.hasNext()){
            System.out.println(columns.next());
        }


I get "java.sql.SQLException: Stream has already been closed". The problem seems to be with the data_default column of type LONG. If I comment it out, the code works either way.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 28, 2003 7:17 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
This is a bug in the Oracle JDBC driver (yes, Yet Another!) that can uausally be worked around by putting the LONG column _last_ in the mapping, ie.

Code:
<class name="Column" mutable="false"  table="user_tab_cols">
        <composite-id>
            <key-many-to-one name="table" class="Table" column="table_name"/>           
            <key-property name="name" column="column_name" type="string" length="30" />       
        </composite-id>
       
        <property name="dataType" column="data_type" length="106" not-null="false" type="string"/>
        <property name="length" column="data_length" not-null="true" type="java.lang.Long"/>       
        <property name="precision" column="data_precision" not-null="false" type="java.lang.Long"/>       
        <property name="scale" column="data_scale" not-null="false" type="java.lang.Long"/>
        <property name="nullable" column="nullable" length="1" not-null="false" type="string"/>
        <property name="sequence" column="column_id" not-null="false" type="java.lang.Long"/>
        <property name="defaultValue" column="data_default" not-null="false" type="string"/>
    </class>


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 28, 2003 7:24 pm 
Newbie

Joined: Thu Aug 28, 2003 11:49 am
Posts: 15
Location: Calgary, Alberta, Canada
That doesn't work for me. Does it depend on the version of the JDBC driver? I tried ojdbc14.jar and classes12.zip

PS. This new forum is SO much better!


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 28, 2003 7:29 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
uggh!

what does the generated SQL look like?


The bug I know about is that Oracle closes any stream apart from the *last* column in the SELECT clause. So the trick is to get Hibernate to put that column last in the select clause.

If that doesn't help, I really don't know. Oracle JDBC driver is a real pain.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 29, 2003 10:10 am 
Newbie

Joined: Thu Aug 28, 2003 11:49 am
Posts: 15
Location: Calgary, Alberta, Canada
I modified the mapping like this:
Code:
    <!-- key-many-to-one name="table" class="Table" column="table_name"/-->
    <key-property name="tableName" column="table_name" length="30" type="string"/>

and now it works. Two SQL statements were being issued, one to resolve the columns and the other to instantiate the table. Not a great solution, but it is a viable workaround. Do you have any idea what happens if I have multiple LONG columns. Can I just place them all at the end?[/code]


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 29, 2003 3:12 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Nah, you can use one only. Oracle jdbc driver is a bitch.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.