-->
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.  [ 3 posts ] 
Author Message
 Post subject: Problem with Hibernate when storing Blob data to Oracle DB
PostPosted: Thu May 27, 2004 10:55 am 
Newbie

Joined: Thu May 27, 2004 10:42 am
Posts: 2
Hi,

I have problems in storing blob data to Oracle through Hibernate.
I followed the sample on http://www.hibernate.org/73.html. I am able to retrieve the data but not able to store the data.

When I am trying to store the data, I get this exception

Root cause of the problem is

Root cause: java.lang.ClassCastException
at oracle.jdbc.driver.OraclePreparedStatement.setBlob(OraclePreparedStat
ement.java:2056)
at com.futrend.trainingsystem.communications.BinaryBlobType.nullSafeSet(
Unknown Source)
at net.sf.hibernate.type.CustomType.nullSafeSet(CustomType.java:118)


Entire Exception Log is as follows:

Hibernate: insert into etcivdev.ATTACHMENTS (FILE_NAME, FILE_CONTENT, EXTRA_VAR1
, EXTRA_NUM1, EXTRA_DATE1, ID) values (?, ?, ?, ?, ?, ?)
ERROR [05/26/04 09:18:43] - java.lang.ClassCastException
com.futrend.trainingsystem.persistence.PersistenceException: Exception in Hibern
ateAttachmentsPersistenceManager
at com.futrend.trainingsystem.persistence.hibernate.HibernateAttachments
PersistenceManager.createAttachment(Unknown Source)
at com.futrend.trainingsystem.communications.StoreFileBean.storeInDataba
se(Unknown Source)
at com.futrend.trainingsystem.communications.StoreFileBean.storeFile(Unk
nown Source)
at com.futrend.trainingsystem.communications.FileReadServlet.doPost(Unkn
own Source)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:763)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:284)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:204)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
alve.java:257)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValv
eContext.java:151)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
a:567)
at org.apache.catalina.core.StandardContextValve.invokeInternal(Standard
ContextValve.java:245)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
alve.java:199)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValv
eContext.java:151)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(Authentica
torBase.java:509)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValv
eContext.java:149)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
a:567)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
ava:184)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValv
eContext.java:151)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
ava:164)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValv
eContext.java:149)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
a:567)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
ve.java:156)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValv
eContext.java:151)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
a:567)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:972)

at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:20
6)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java
:833)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.proce
ssConnection(Http11Protocol.java:732)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java
:619)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadP
ool.java:688)
at java.lang.Thread.run(Thread.java:534)
Caused by: java.lang.ClassCastException
at oracle.jdbc.driver.OraclePreparedStatement.setBlob(OraclePreparedStat
ement.java:2056)
at com.futrend.trainingsystem.communications.BinaryBlobType.nullSafeSet(
Unknown Source)
at net.sf.hibernate.type.CustomType.nullSafeSet(CustomType.java:118)
at net.sf.hibernate.persister.EntityPersister.dehydrate(EntityPersister.
java:393)
at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.jav
a:466)
at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.jav
a:442)
at net.sf.hibernate.impl.ScheduledInsertion.execute(ScheduledInsertion.j
ava:29)
at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2382)
at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2335)
at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2204)
at net.sf.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.j
ava:61)
... 32 more
Root cause: java.lang.ClassCastException
at oracle.jdbc.driver.OraclePreparedStatement.setBlob(OraclePreparedStat
ement.java:2056)
at com.futrend.trainingsystem.communications.BinaryBlobType.nullSafeSet(
Unknown Source)
at net.sf.hibernate.type.CustomType.nullSafeSet(CustomType.java:118)
at net.sf.hibernate.persister.EntityPersister.dehydrate(EntityPersister.
java:393)
at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.jav
a:466)
at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.jav
a:442)
at net.sf.hibernate.impl.ScheduledInsertion.execute(ScheduledInsertion.j
ava:29)
at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2382)
at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2335)
at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2204)
at net.sf.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.j
ava:61)
at com.futrend.trainingsystem.persistence.hibernate.HibernateAttachments
PersistenceManager.createAttachment(Unknown Source)
at com.futrend.trainingsystem.communications.StoreFileBean.storeInDataba
se(Unknown Source)
at com.futrend.trainingsystem.communications.StoreFileBean.storeFile(Unk
nown Source)
at com.futrend.trainingsystem.communications.FileReadServlet.doPost(Unkn
own Source)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:763)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:284)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:204)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
alve.java:257)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValv
eContext.java:151)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
a:567)
at org.apache.catalina.core.StandardContextValve.invokeInternal(Standard
ContextValve.java:245)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
alve.java:199)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValv
eContext.java:151)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(Authentica
torBase.java:509)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValv
eContext.java:149)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
a:567)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
ava:184)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValv
eContext.java:151)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
ava:164)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValv
eContext.java:149)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
a:567)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
ve.java:156)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValv
eContext.java:151)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
a:567)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:972)

at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:20
6)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java
:833)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.proce
ssConnection(Http11Protocol.java:732)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java
:619)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadP
ool.java:688)
at java.lang.Thread.run(Thread.java:534)
Root cause: java.lang.ClassCastException
at oracle.jdbc.driver.OraclePreparedStatement.setBlob(OraclePreparedStat
ement.java:2056)
at com.futrend.trainingsystem.communications.BinaryBlobType.nullSafeSet(
Unknown Source)
at net.sf.hibernate.type.CustomType.nullSafeSet(CustomType.java:118)
at net.sf.hibernate.persister.EntityPersister.dehydrate(EntityPersister.
java:393)
at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.jav
a:466)
at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.jav
a:442)
at net.sf.hibernate.impl.ScheduledInsertion.execute(ScheduledInsertion.j
ava:29)
at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2382)
at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2335)
at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2204)
at net.sf.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.j
ava:61)
at com.futrend.trainingsystem.persistence.hibernate.HibernateAttachments
PersistenceManager.createAttachment(Unknown Source)
at com.futrend.trainingsystem.communications.StoreFileBean.storeInDataba
se(Unknown Source)
at com.futrend.trainingsystem.communications.StoreFileBean.storeFile(Unk
nown Source)
at com.futrend.trainingsystem.communications.FileReadServlet.doPost(Unkn
own Source)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:763)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:284)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:204)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
alve.java:257)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValv
eContext.java:151)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
a:567)
at org.apache.catalina.core.StandardContextValve.invokeInternal(Standard
ContextValve.java:245)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
alve.java:199)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValv
eContext.java:151)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(Authentica
torBase.java:509)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValv
eContext.java:149)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
a:567)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
ava:184)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValv
eContext.java:151)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
ava:164)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValv
eContext.java:149)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
a:567)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
ve.java:156)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValv
eContext.java:151)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
a:567)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:972)

at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:20
6)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java
:833)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.proce
ssConnection(Http11Protocol.java:732)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java
:619)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadP
ool.java:688)
at java.lang.Thread.run(Thread.java:534)




Here is the working environment

1. Oracle 9i Personal Edition
2. JDBC driver: Oracle Thin driver (classes12.zip)
3. Tomcat 5.0.19
4. Hibernate 2



I have one more question, does Hibernate Support BLOBs? If so why is this problem.

I haven't tried this code with other databases. Am I going to get the same problem with other databases also?

I would greatly appreciate the response.

Thanks
Ravitha


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 28, 2004 11:42 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
Yes, Hibernate supports JDBC compliant LOBs. Unfortunately, while Oracle is probably the best overall RDBMS out there, its JDBC support is (shall we say) lacking. I have worked with all Oracle releases up through the latest 8i versions, but have not played with 9i at all so some of these shortcomings may have changed in those 9i releases. A lot of the shortcomings dealt with the way things were implemented on the server itself (like non-scrollable cursors and LOB support), while others were just silliness (like saying they support the XOpen sql extension functions when they really do not).

Because of this "non-standard" approach to LOBs, you need to handle CLOBS and BLOBS differently if using Oracle. Unfortunately, thats just a fact of using Oracle. Check the url below for more info.


http://www.hibernate.org/56.html


Top
 Profile  
 
 Post subject:
PostPosted: Sat May 29, 2004 1:13 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Please, Oracle users, go and complain to /Oracle/ about their bugs. You have paid them a LOT of money and they should bloody well fix their own crap code. There is nothing we can do about Oracle's broken JDBC driver.

Call them up. Yell at them. Ask for your money back. Make a big stink about this! It is just unacceptable that these issues persist after so many years.


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