• 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
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Spring-Hibernate-Blob problem

 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Great Ranchers,

I am facing problem while saving Blob object (which represents a file being uploaded). When I run this code I don't get my object saved. Please suggest where I am missing something to get code working properly.



Employee.java

public class Employee implements Serializable {
long id;
private String name;
private String department;
private String projectTitle;
private String projectDescription;
private Blob content;
...................................


Employee.hbm.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping>
<class name="com.test.beans.Employee" table="Employee">
<id name="id" type="long" column="ID">
<generator class="assigned" />
</id>

<property name="content" type="blob">
<column name="CONTENT" />
</property>
...................................


MyDaoImpl.java

Blob blob = null;
InputStream in = file.getInputStream(); //File being uploaded
blob = Hibernate.createBlob(in);
employee.setContent(blob);
hibernateTemplate.saveOrUpdate(employee);
.......................................................


Thanks & Best Regards
Maneesh Saxena
 
Maneeesh Saxena
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

Now I am able to upload file in database now the problem is I've to download the file. I've googled a lot but could not find any web app for doing the same please help me in this ...


Best Regards
Maneesh Saxena
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I believe this article I wrote recently, might be relevant to your question...

In the article I used Spring Roo for its implementation, however I refer to another implementaion using regular Spring too.

Here is the link: http://viralpatel.net/blogs/2011/02/spring-roo-save-read-blob-object-spring-roo-tutorial.html.

I hope it helps you

jD
 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic