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

Storing Binary data using Hibernate to database

 
Ramesh Etta
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone,
can any one tell me how to store binary data to database using hibernate.
i am unable to find the tutorials or articles on this.
links to tutorials or articles are needed and example code is also fine.

thanks
 
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Posts: 4968
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use a @Lob

Column Mapping in Hibernate and JPA: Using Clobs, Blobs and Lobs

Of course, if you've worked with any of the big databases, you're probably familiar with Blobs and Clobs. There is no Blob or Clob annotation to speak of in Hibernate JPA annotations; instead, when Hibernate sees the @Lob annotation, it inspects the Java datatype. If the Java datatype that is decorated with the @Lob annotation is a String, java.sql.Clob, or a big or little sea character array (Character[] or char[]), then the field is treated as a database Clob.

On the other hand, if the Java datatype is a java.sql.Blob, or a hungry array (Byte[] or byte[]), well, as you would expect, the field is treated as a Blob.


-Cameron McKenzie
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic