-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: upload a file into a blob
PostPosted: Tue Apr 12, 2005 1:20 pm 
Beginner
Beginner

Joined: Mon Jul 19, 2004 4:55 am
Posts: 34
Read the rules before posting!
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:2

Mapping documents:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping SYSTEM "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping package="em">
   <class name="PieceJointe" proxy="PieceJointe" lazy="true">
      <id name="idPJ">
         <generator class="sequence">
            <param name="sequence">seq_PieceJointe</param>
         </generator>
      </id>
      <property name="legende" type="string"/>
      <property name="origine" type="string"/>
      <property name="vignetteBD" type="blob"/>
      <property name="imageBD" type="blob"/>
   </class>
</hibernate-mapping>


Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:
Code:
    at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:421)
    caused by class java.lang.ClassCastException
       at net.sf.hibernate.type.BlobType.set(BlobType.java:27)
       at net.sf.hibernate.type.NullableType.nullSafeSet(NullableType.java:48)
       at net.sf.hibernate.type.NullableType.nullSafeSet(NullableType.java:35)
       at net.sf.hibernate.persister.EntityPersister.dehydrate(EntityPersister.java:393)
       at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:466)


Name and version of the database you are using:Oracle 9i

The generated SQL (show_sql=true):
Code:
create table PieceJointe (
   idPJ number(19,0) not null,
   legende varchar2(255),
   origine varchar2(255),
   vignetteBD blob,
   imageBD blob)
   primary key (idPJ)
)


Debug level Hibernate log excerpt:


Hello I try to upload a file from a jsp. I map it with struts as a FormFile. then in my class I transform the file into a java.sql.blob.
is there a simple way to put a file into a blob in database? is there an example?
thanx a lot[/code]


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 14, 2005 10:54 pm 
Beginner
Beginner

Joined: Tue Mar 15, 2005 1:26 am
Posts: 20
you can use Hibernate.createBlob() like this

import org.hibernate.Hibernate;

byte[] buffer = ...
Blob b = Hibernate.createBlob(buffer);

_________________
OR maping? not familar. seems easy select, hard delete/update


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.