Results 1 to 4 of 4

Thread: Strange Blob Problem - Ends Up Entirely Corrupted?

  1. #1
    Join Date
    Nov 2004
    Posts
    21

    Default Strange Blob Problem - Ends Up Entirely Corrupted?

    Hi,

    I'm using spring and hibernate, and have a strange blob problem. I use Xdoclet and map a blob field into the DB with a normal:

    Code:
    type="org.springframework.orm.hibernate.support.BlobByteArrayType"
    mapping, and this generates by blob table field and all is good. I can store normal data in there, and don't have any problems... until I try to store encrypted data.

    I have an application that stores normal data in some blobs (text, file data, etc..) and encrypted data in some blobs (the raw encrypted output). The problem is.. when I store the raw encrypted data, it silently fails and stores the data as a totally munged data.

    The odd thing.. when I store it, lets say I'm storing a byte array of 208 bytes.. if a select length(blobfield) from the database, it says 208 bytes.. but when I read that blob back in its 104 bytes.

    Now.. if I simplify the encoding of the data by, say, Hex encoding it before storing it in the blob... no problem. It stores fine, and retrieves fine.

    Now, I use this Blob handler all over my app, and this is the only place I have this problem. Any ideas on what the heck is going on?

    By the way, this is with a MySQL 4 database and blob/longblob fields. I'm using an INNODB backend, and Hibernate / Spring's Blob handlers in this application.

    Any pointers would be great! Thanks!

  2. #2
    Join Date
    Jan 2005
    Location
    Bucharest, Romania
    Posts
    5,403

    Default

    It's clearly a problem with your db settings. Most probably your blob contains 2 bytes character in encrypted format and mysql uses only 1 byte format for storage. See what are mysql options for storing binary/raw format (from my experience I know they tend to do things their own way).

    If possible try also other database (like postgresql) and see how it handles the problem - this way you can figure out how to store your encrypted information in a common format that will work on most dbs.
    Costin Leau
    SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
    http://twitter.com/costinl
    Please use [ c o d e ] [ / c o d e ] tags

  3. #3
    Join Date
    Nov 2004
    Posts
    21

    Default Thats my thinking..

    I would agree.. I haven't tried another DB, though I will be due to my requirements anyway.. but I wanted to see if anybody else has had this problem in storing the raw bytes through the Spring/Hibernate layer.

    I've used Hibernate for storing BLOB's in the past, but without Spring's layer on top of that. I wanted to see if I was doing something odd in that interaction, but the spring code seems pretty straightforward in that area.

    I store other blobs in the same application, but without a problem. I guess this is a post for the MySQL forums..

    thanks!

  4. #4
    Join Date
    Jan 2005
    Location
    Bucharest, Romania
    Posts
    5,403

    Default

    I suggest then to seek the differences between your previous HB code and the one in Spring. Probably you have the HB's data source configured different or maybe the session factory (though less likely).
    This happens especially because many people switch to Commons-DBCP w/ Spring from c3p0.
    Costin Leau
    SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
    http://twitter.com/costinl
    Please use [ c o d e ] [ / c o d e ] tags

Similar Threads

  1. Replies: 9
    Last Post: Feb 1st, 2008, 08:29 PM
  2. Strange and bizarre jsp compilation problem:
    By Colin Yates in forum Web
    Replies: 1
    Last Post: Aug 19th, 2005, 06:08 AM
  3. really strange problem with session
    By a_wronski in forum Security
    Replies: 2
    Last Post: Jun 24th, 2005, 10:23 PM
  4. Strange problem setting a property
    By kdenehy in forum Container
    Replies: 8
    Last Post: Apr 28th, 2005, 09:16 PM
  5. Replies: 2
    Last Post: Nov 21st, 2004, 06:23 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •