[jboss-user] [EJB 3.0] - Blob Tutorial

ccharpentier do-not-reply at jboss.com
Wed Aug 23 05:30:17 EDT 2006


I try to use the blob tutorial and modify it.

I want to test with fileInput
 in the bean to create from file, it 's working

  | public long create()
  |    {
  |       BlobEntity blob = new BlobEntity();
  | 
  |       File file = new File("D:\\data.dat");
  |       int fileLength = (int) file.length();
  | try {
  | 	FileInputStream  fileinp = new FileInputStream(file);
  | 		
  |          blob.setBlobby(Hibernate.createBlob(fileinp));
  |       }
  |       catch (IOException e)
  |       {
  |          throw new RuntimeException(e);
  |       }
  | }
  | 
  | 

but Ican not manage to get my file from the blob

I try lot of thing, I get some Serialisation error
here the code to find blob


  | public InputStream findBlob(long id) throws Exception
  |    {
  |       BlobEntity blob = manager.find(BlobEntity.class, id);
  |       ObjectInputStream ois = new ObjectInputStream(blob.getBlobby().getBinaryStream());
  |       return (InputStream) ois.readObject();
  |    }
  | 

how I can get the file stream?

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3966909#3966909

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3966909



More information about the jboss-user mailing list