-->
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.  [ 1 post ] 
Author Message
 Post subject: BLOB - BYTE mapping in JTA environment causing SQLException.
PostPosted: Tue Jul 21, 2009 9:57 am 
Newbie

Joined: Tue Jul 21, 2009 9:38 am
Posts: 1
I have mapped the BLOB columns to byte[] as per the blog(http://hansonchar.blogspot.com/2005/06/oracle-blob-mapped-to-byte-in.html) and deployed in a JTA environment.

Now this peace of code.
Code:
Query query = getSession().
                        getNamedQuery("LetterTemplate").
                        setLong("letterID", letterTemplateSearchCriteria.getLetterID());
                template = (LetterTemplateDO) query.uniqueResult();

                /* Setting the blog content into the byte array of same object  */
                if (null != template && null != template.getLetterTemplate()) {
                    template.setLetterTemplateStream(
                            template.getLetterTemplate().getBytes(1,
                            (int) (template.getLetterTemplate().length())));
                }


is throwing a

java.sql.SQLException: Closed Connection
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:208)
at oracle.sql.BLOB.getDBAccess(BLOB.java:955)
at oracle.sql.BLOB.length(BLOB.java:155)


at this line

template.setLetterTemplateStream(
template.getLetterTemplate().getBytes(1,
(int) (template.getLetterTemplate().length())));

Did some google on this error and some analysis of the log file got to know,

1. The JDBC connection will be closed as soon as the Query is executed (http://docs.jboss.org/hibernate/stable/core/reference/en/html_single/#configuration-optional, find hibernate.connection.release_mode), which will result in connection closed error.

2. Log from the application:

18:41:22.729 [httpSSLWorkerThread-8080-1] DEBUG org.hibernate.jdbc.AbstractBatcher - about to open ResultSet (open ResultSets: 0, globally: 0)
18:41:22.729 [httpSSLWorkerThread-8080-1] DEBUG org.hibernate.loader.Loader - result row: EntityKey[ca.medavie.systemsetup.data.domain.LetterTemplateDO#103]
18:41:22.729 [httpSSLWorkerThread-8080-1] DEBUG org.hibernate.jdbc.AbstractBatcher - about to close ResultSet (open ResultSets: 1, globally: 1)
18:41:22.729 [httpSSLWorkerThread-8080-1] DEBUG org.hibernate.jdbc.AbstractBatcher - about to close PreparedStatement (open PreparedStatements: 4, globally: 4)
18:41:22.729 [httpSSLWorkerThread-8080-1] DEBUG org.hibernate.jdbc.ConnectionManager - aggressively releasing JDBC connection
18:41:22.729 [httpSSLWorkerThread-8080-1] DEBUG org.hibernate.jdbc.ConnectionManager - releasing JDBC connection [ (open PreparedStatements: 3, globally: 3) (open ResultSets: 0, globally: 0)]
18:41:22.729 [httpSSLWorkerThread-8080-1] DEBUG o.h.e.StatefulPersistenceContext - initializing non-lazy collections
18:41:22.729 [httpSSLWorkerThread-8080-1] ERROR c.m.g.c.d.Impl - Error occured during retrieval


Also somehow (i'm wondering) it used to work previosuly. This this is unpredictable and causing lot of problem.

I'm requesting help to make this code working in JTA environment(Glass fish, Oracle) with consistent behavior ? Please suggest some options.

Thanks for the help in advance.


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

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.