-->
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.  [ 4 posts ] 
Author Message
 Post subject: Oracle problem, SQLException: Stream has already been closed
PostPosted: Fri May 07, 2004 11:34 am 
Newbie

Joined: Thu May 06, 2004 10:10 am
Posts: 14
Hi all,

While testing Hibernate for use in a project (i have been assigned to test hibernate, a colleague of mine is testing Torque).

I am running into a problem that I have been unable to solve, even though there are postings about this problem on this forum:

http://forum.hibernate.org/viewtopic.php?t=82

The property causing the problem (i think) is the 'BODY' column. It is of Oracle type Long. I have tried moving its <property> entry in order to modify the query as suggested by Gavin in the topic in the above link, but the query remains unaffected and so the problem persists.

I am hoping someone can take a look at the specifics of my case, since the solution that worked for the person in the above topic doesn't really apply to my case.

The case is simple: I am trying to retrieve a product object. The product object has a member called 'body' which is a long description of the product. Furthermore, it is associated to a category.

Any help is greatly apreciated! :-)
Code:
Session session = sessionFactory.openSession();
Product p = (Product) session.load(Product.class, new Integer(1));
session.close();


My platform info:
Hibernate 2.1.3
Oracle 9i, driver: ojdbc14.jar
JDK 1.4

My mapping file looks like this:
Code:
<class name="shop.entities.Product" table="PRODUCTS">
    <id name="id" type="int" column="ID">
        <generator class="sequence">
            <param name="sequence">PRODUCT_SEQ</param>
        </generator>
    </id>
    <property name="name" type="java.lang.String" column="NAME" length="255" />
    <!-- associations -->
    <!-- bi-directional one-to-many association to Shipmentcontent -->
    <set name="shipmentcontents" lazy="true" inverse="true">
        <key>
            <column name="PRODUCT_ID" />
        </key>
        <one-to-many class="shop.entities.Shipmentcontent"/>
    </set>
    <!-- bi-directional many-to-one association to Category -->
    <many-to-one name="category" class="shop.entities.Category" not-null="true">
        <column name="CATEGORY_ID" />
    </many-to-one>
    <property name="body" type="java.lang.String" column="BODY"/>
</class>


This is the info output hibernate generates:
May 7, 2004 5:25:03 PM net.sf.hibernate.cfg.Environment <clinit>
INFO: Hibernate 2.1.3
May 7, 2004 5:25:03 PM net.sf.hibernate.cfg.Environment <clinit>
INFO: loaded properties from resource hibernate.properties: {hibernate.connection.driver_class=oracle.jdbc.driver.OracleDriver, hibernate.cglib.use_reflection_optimizer=true, hibernate.max_fetch_depth=1, hibernate.dialect=net.sf.hibernate.dialect.OracleDialect, hibernate.jdbc.use_streams_for_binary=true, hibernate.jdbc.batch_size=0, hibernate.query.substitutions=true 1, false 0, yes 'Y', no 'N', hibernate.proxool.pool_alias=pool1, hibernate.connection.username=hans, hibernate.cache.region_prefix=hibernate.test, hibernate.connection.url=jdbc:oracle:thin:@localhost:1521:krol1, hibernate.show_sql=true, hibernate.connection.password=haha, hibernate.connection.pool_size=1}
May 7, 2004 5:25:03 PM net.sf.hibernate.cfg.Environment <clinit>
INFO: using java.io streams to persist binary types
May 7, 2004 5:25:03 PM net.sf.hibernate.cfg.Environment <clinit>
INFO: using CGLIB reflection optimizer
May 7, 2004 5:25:03 PM net.sf.hibernate.cfg.Configuration addFile
INFO: Mapping file: Category.hbm.xml
May 7, 2004 5:25:04 PM net.sf.hibernate.cfg.Binder bindRootClass
INFO: Mapping class: shop.entities.Category -> CATEGORIES
May 7, 2004 5:25:05 PM net.sf.hibernate.cfg.Configuration addFile
INFO: Mapping file: Product.hbm.xml
May 7, 2004 5:25:05 PM net.sf.hibernate.cfg.Binder bindRootClass
INFO: Mapping class: shop.entities.Product -> PRODUCTS
May 7, 2004 5:25:05 PM net.sf.hibernate.cfg.Configuration addFile
INFO: Mapping file: Shipment.hbm.xml
May 7, 2004 5:25:05 PM net.sf.hibernate.cfg.Binder bindRootClass
INFO: Mapping class: shop.entities.Shipment -> SHIPMENTS
May 7, 2004 5:25:05 PM net.sf.hibernate.cfg.Configuration addFile
INFO: Mapping file: Client.hbm.xml
May 7, 2004 5:25:05 PM net.sf.hibernate.cfg.Binder bindRootClass
INFO: Mapping class: shop.entities.Client -> CLIENTS
May 7, 2004 5:25:05 PM net.sf.hibernate.cfg.Configuration addFile
INFO: Mapping file: Shipmentcontent.hbm.xml
May 7, 2004 5:25:05 PM net.sf.hibernate.cfg.Binder bindRootClass
INFO: Mapping class: shop.entities.Shipmentcontent -> SHIPMENTCONTENT
May 7, 2004 5:25:06 PM net.sf.hibernate.cfg.Configuration secondPassCompile
INFO: processing one-to-many association mappings
May 7, 2004 5:25:06 PM net.sf.hibernate.cfg.Binder bindCollectionSecondPass
INFO: Mapping collection: shop.entities.Category.products -> PRODUCTS
May 7, 2004 5:25:06 PM net.sf.hibernate.cfg.Binder bindCollectionSecondPass
INFO: Mapping collection: shop.entities.Category.subCategories -> CATEGORIES
May 7, 2004 5:25:06 PM net.sf.hibernate.cfg.Binder bindCollectionSecondPass
INFO: Mapping collection: shop.entities.Product.shipmentcontents -> SHIPMENTCONTENT
May 7, 2004 5:25:06 PM net.sf.hibernate.cfg.Binder bindCollectionSecondPass
INFO: Mapping collection: shop.entities.Shipment.shipmentcontents -> SHIPMENTCONTENT
May 7, 2004 5:25:06 PM net.sf.hibernate.cfg.Binder bindCollectionSecondPass
INFO: Mapping collection: shop.entities.Client.shipments -> SHIPMENTS
May 7, 2004 5:25:06 PM net.sf.hibernate.cfg.Configuration secondPassCompile
INFO: processing one-to-one association property references
May 7, 2004 5:25:06 PM net.sf.hibernate.cfg.Configuration secondPassCompile
INFO: processing foreign key constraints
May 7, 2004 5:25:06 PM net.sf.hibernate.dialect.Dialect <init>
INFO: Using dialect: net.sf.hibernate.dialect.OracleDialect
May 7, 2004 5:25:06 PM net.sf.hibernate.cfg.SettingsFactory buildSettings
INFO: Maximim outer join fetch depth: 1
May 7, 2004 5:25:06 PM net.sf.hibernate.cfg.SettingsFactory buildSettings
INFO: Use outer join fetching: true
May 7, 2004 5:25:06 PM net.sf.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Using Hibernate built-in connection pool (not for production use!)
May 7, 2004 5:25:06 PM net.sf.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Hibernate connection pool size: 1
May 7, 2004 5:25:06 PM net.sf.hibernate.connection.DriverManagerConnectionProvider configure
INFO: using driver: oracle.jdbc.driver.OracleDriver at URL: jdbc:oracle:thin:@krol.neteffect.nl:1521:krol1
May 7, 2004 5:25:06 PM net.sf.hibernate.connection.DriverManagerConnectionProvider configure
INFO: connection properties: {user=hans, password=hans}
May 7, 2004 5:25:06 PM net.sf.hibernate.transaction.TransactionManagerLookupFactory getTransactionManagerLookup
INFO: No TransactionManagerLookup configured (in JTA environment, use of process level read-write cache is not recommended)
May 7, 2004 5:25:09 PM net.sf.hibernate.cfg.SettingsFactory buildSettings
INFO: Use scrollable result sets: true
May 7, 2004 5:25:09 PM net.sf.hibernate.cfg.SettingsFactory buildSettings
INFO: Use JDBC3 getGeneratedKeys(): false
May 7, 2004 5:25:09 PM net.sf.hibernate.cfg.SettingsFactory buildSettings
INFO: Optimize cache for minimal puts: false
May 7, 2004 5:25:09 PM net.sf.hibernate.cfg.SettingsFactory buildSettings
INFO: echoing all SQL to stdout
May 7, 2004 5:25:09 PM net.sf.hibernate.cfg.SettingsFactory buildSettings
INFO: Query language substitutions: {no='N', true=1, yes='Y', false=0}
May 7, 2004 5:25:09 PM net.sf.hibernate.cfg.SettingsFactory buildSettings
INFO: cache provider: net.sf.ehcache.hibernate.Provider
May 7, 2004 5:25:09 PM net.sf.hibernate.cfg.Configuration configureCaches
INFO: instantiating and configuring caches
May 7, 2004 5:25:09 PM net.sf.hibernate.impl.SessionFactoryImpl <init>
INFO: building session factory
May 7, 2004 5:25:10 PM net.sf.hibernate.impl.SessionFactoryObjectFactory addInstance
INFO: no JNDI name configured
Hibernate: select product0_.ID as ID1_, product0_.NAME as NAME1_, product0_.CATEGORY_ID as CATEGORY3_1_, product0_.BODY as BODY1_, category1_.ID as ID0_, category1_.NAME as NAME0_, category1_.PARENT_ID as PARENT_ID0_ from PRODUCTS product0_, CATEGORIES category1_ where product0_.ID=? and product0_.CATEGORY_ID=category1_.ID(+)
May 7, 2004 5:25:11 PM net.sf.hibernate.util.JDBCExceptionReporter logExceptions
WARNING: SQL Error: 17027, SQLState: null
May 7, 2004 5:25:11 PM net.sf.hibernate.util.JDBCExceptionReporter logExceptions
SEVERE: Stream has already been closed
May 7, 2004 5:25:11 PM net.sf.hibernate.util.JDBCExceptionReporter logExceptions
WARNING: SQL Error: 17027, SQLState: null
May 7, 2004 5:25:11 PM net.sf.hibernate.util.JDBCExceptionReporter logExceptions
SEVERE: Stream has already been closed
May 7, 2004 5:25:11 PM net.sf.hibernate.JDBCException <init>
SEVERE: could not load: [shop.entities.Product#1]
java.sql.SQLException: Stream has already been closed
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:179)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:269)
at oracle.jdbc.ttc7.LongTTCItem.getChars(LongTTCItem.java:189)
at oracle.jdbc.dbaccess.DBDataSetImpl.getCharsStreamItem(DBDataSetImpl.java:1629)
at oracle.jdbc.driver.OracleStatement.getCharsInternal(OracleStatement.java:3530)
at oracle.jdbc.driver.OracleStatement.getStringValue(OracleStatement.java:3739)
at oracle.jdbc.driver.OracleResultSetImpl.getString(OracleResultSetImpl.java:460)
at oracle.jdbc.driver.OracleResultSet.getString(OracleResultSet.java:1482)
at net.sf.hibernate.type.StringType.get(StringType.java:18)
at net.sf.hibernate.type.NullableType.nullSafeGet(NullableType.java:62)
at net.sf.hibernate.type.NullableType.nullSafeGet(NullableType.java:53)
at net.sf.hibernate.type.AbstractType.hydrate(AbstractType.java:66)
at net.sf.hibernate.loader.Loader.hydrate(Loader.java:611)
at net.sf.hibernate.loader.Loader.loadFromResultSet(Loader.java:552)
at net.sf.hibernate.loader.Loader.instanceNotYetLoaded(Loader.java:511)
at net.sf.hibernate.loader.Loader.getRow(Loader.java:426)
at net.sf.hibernate.loader.Loader.doQuery(Loader.java:209)
at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:133)
at net.sf.hibernate.loader.Loader.loadEntity(Loader.java:836)
at net.sf.hibernate.loader.Loader.loadEntity(Loader.java:856)
at net.sf.hibernate.loader.EntityLoader.load(EntityLoader.java:59)
at net.sf.hibernate.loader.EntityLoader.load(EntityLoader.java:51)
at net.sf.hibernate.persister.EntityPersister.load(EntityPersister.java:419)
at net.sf.hibernate.impl.SessionImpl.doLoad(SessionImpl.java:2106)
at net.sf.hibernate.impl.SessionImpl.doLoadByClass(SessionImpl.java:1980)
at net.sf.hibernate.impl.SessionImpl.load(SessionImpl.java:1909)
at shop.Shop.<init>(Shop.java:66)
at shop.Shop.main(Shop.java:29)


[/code][/url]


Top
 Profile  
 
 Post subject:
PostPosted: Sat May 08, 2004 8:55 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
disable outer join fetching of the Category.

This is a nasty oracle bug, I wish they would fix it.


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 10, 2004 9:36 am 
Newbie

Joined: Thu May 06, 2004 10:10 am
Posts: 14
Thanx, that solved the problem...

Any idea why Oracle is taking so long to fix this? It would be nice indeed if it got out of our way :-)

byebye,
mirror303


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 20, 2007 6:24 am 
Newbie

Joined: Fri Mar 23, 2007 4:47 am
Posts: 16
It is the year 2007 and still oracle hasnt solved it. They are really lazy.

Since my original post I have discovered that is better to not use Long columns at all. Use clob or blob instead.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.