Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Handling Oracle Blob with Hibernate

 
Prince Manchanda
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to save a file(word doc/pdf etc) into Oracle 8i database using hibernate. My table column is of type BLOB and I am using
to create blob object in my bean.
I am running it as a standalone java application.The code the handles the DB access is :

Now when I run this code my execution gets stucks after that is program does nothing and no exception is thrown. Here is the copy-paste from console:

INFO: Not binding factory to JNDI, no JNDI name configured
##############SessionFactory created...
##############Got Session
##############Transaction Started...
Saving DTO
##############DTO Saved
Hibernate: insert into pm_test (dd, id) values (?, ?)

Any ideas what I am doing wrong in my code that causes the implementation to halt.

Thanks a lot
[ May 20, 2008: Message edited by: Prince Manchanda ]
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How long have you waited? How big is your BLOB?
 
Prince Manchanda
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have waited for couple of hours. The size of the document that I am trying to save is 24kb.
Another interesting point is that I am able to save the save document to same table in the database using JDBC code. Even saving a 2.3 MB document works fine.
Any help in this regard will be appreciated.
 
Edvins Reisons
Ranch Hand
Posts: 364
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you sure that you have read the file before closing the input stream?
 
Rajah Nagur
Ranch Hand
Posts: 239
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I recommend to implement your own org.hibernate.usertype.UserType.
Something like below:


and manually set the blob in the PreparedStatment
 
Rajah Nagur
Ranch Hand
Posts: 239
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I recommend to implement your own org.hibernate.usertype.UserType.
Something like below:


and manually set the blob in the PreparedStatment
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic