• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem with Hibernate + Firebird + Blob field

 
Leticia Barbalho
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everyone,

I've been trying, but it seems impossible to do the simplest thing in the world: store a String into a Blob. (Before you ask me why I don't use varchar: believe me, I would if I could)

I've tried many ways to do it, but each way gives me a different problem. I tried mapping it as a binary as using my getters and setters as byte[]; I tried mapping it as a blob and using my getters and setters as blob; I tried this: http://www.hibernate.org/73.html. Each one gives me a different error... the first way inserts a corrupted string, the second says there's a type mismatch, the third says I must use some FBBlob thing I never heard about.

So what I want now is to hear from someone who has inserted anything (not necessarily a String) in a Blob in Firebird using Hibernate. I must know what you did, and I must believe this person exists, for I'm starting to think it's impossible...

Thanks in advance.
 
Yilmaz Mete
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you are probably using String.getBytes() to get the byte []
I guess you should explicitly state it as UTF both writing to the BLOB and reading from the BLOB.
try!
 
Leticia Barbalho
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not really sure of how I should do it. I tried iterating through the byte[] and converting each position to string, but didn't work. Is that what you're saying?

Thanks you so much.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which dialect are you using? I didn't think Firebird was supported by Hibernate.
 
Leticia Barbalho
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, I looked here: http://www.hibernate.org/80.html and they say it's compatible, using the JayBird driver.
I'm using dialect 3.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ah right. Compatible, but not supported.

In which case I'd check the dialect source. See how blobs have been handled. I don't know Firebird, but I do know that there are certain awkward issues with other databases/drivers and binary data. Might be worth having a search through your driver documentation to see if there are any known limitations with whichever JDBC method the dialect is using.
 
Leticia Barbalho
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've been checking Jaybird's website. I found this:
http://www.firebirdsql.org/index.php?op=devel&sub=jdbc&id=faq#10

I tested here and there's no problem inserting in blob fields WITHOUT hibernate. It's when using hibernate that things don't work.

Has no one tried it before?
 
Martin Cerny
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If anyone else is trying to solve Firebird and Hibernate problem, I wrote some stuff on my blog:
http://babickababa.blogspot.com/2011/01/running-hibernate-and-jpa-with-firebird.html
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic