• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Storing Binary data using Hibernate to database

 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
author and cow tipper
Posts: 5009
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic