-->
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.  [ 1 post ] 
Author Message
 Post subject: Problem with storing CipherInputStream using Blob
PostPosted: Mon Sep 01, 2008 6:54 am 
Newbie

Joined: Sat Aug 18, 2007 2:33 pm
Posts: 2
We are using Hibernate 3.2.4, Jboss 4.0.4 GA, Oracle 10g, EJB 3

We are trying to store Blob into the database - but not all bytes are stored.

The blob is created out of an CipherInputStream (the stream is passed to a local method of an EJB).
The CipherInputStream is created (in the Web Teir) out of FileInputStream and Cipher objects.

Following is part of the local EJB method code:

public void addContent(Content content, CipherInputStream inputStream )throws DBException{


Blob blob = Hibernate.createBlob(inputStream, streamLength);

** Now write the blob into Oracle using Hibernate …

}


In the example we are running, the cipherd stream has 1104 bytes, but only the first 512 bytes of them are eventually stored in the database.

Some clues:

1) inputStream.available() returns 0.

2) When checking the number of bytes of the InputStream of the Blob, ( by reading all bytes of blob.getBinaryStream() ) we get the right number (1104)

3) If we create the Blob without passing the streamLength, e,g:

Blob blob = Hibernate.createBlob(inputStream);

a null will appear in the datatbase

4) If we pass the original FileInputStream to the created Blob all bytes are stored correctly.

Please help,
Eitan

**************************************************

The generated SQL:

insert into CONTENT_STORAGE (CONTENT_FILE, CONTENT_FILE_BIN, CREATION_TIMESTAMP, CONTENT_ID, VERSION) values (?, ?, ?, ?, ?)

The mapping file:

<?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 package=".......dms.contentmanager.model">
<class name="ContentStorage" table="CONTENT_STORAGE" >
<composite-id name="contentPrimaryKey" class="......dms.contentmanager.model.ContentPrimaryKey">
<key-property name="contentId" column="CONTENT_ID" type="string" length="255"></key-property>
<key-property name="version" column="VERSION" type="float" length="255"></key-property>
</composite-id>
<property name="contentFile" column="CONTENT_FILE" type="clob" not-null="false"></property>
<property name="contentFileBin" column="CONTENT_FILE_BIN" type="blob" not-null="false"></property>
<property name="creationTimestamp" column="CREATION_TIMESTAMP" type="timestamp"></property>
</class>
</hibernate-mapping>


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

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.