-->
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: BLOB is corrupted when loading an entity (using postgres)
PostPosted: Thu Jun 30, 2005 5:33 pm 
Newbie

Joined: Fri Apr 02, 2004 9:57 am
Posts: 14
Hi,

I use @Lob to store a password hash in an entity. My problem is that I save 16 bytes, but when the entity is loaded it is only 15 bytes! The first byte is lost!


Details:
I have an entity:

@javax.persistence.Entity
@Entity(dynamicInsert = true, dynamicUpdate = true)
@Table(name = "Users")
public class User extends VersionedPersistentObjectImpl
{
private String userName;

public String getUserName()
{
return userName;
}

public void setUserName(String userName)
{
this.userName = userName;
}

private byte[] passwordHash;

@Lob
@Column(nullable=true)
public byte[] getPasswordHash()
{
return passwordHash;
}

public void setPasswordHash(byte[] passwordHash)
{
this.passwordHash = passwordHash;
}
}

Saving and loading is nothing special. I use Spring's HibernateDaoSupport class to implement DAO functionality.
Before saving I call:

user.setPasswordHash(new byte[] {-44, 29, -116, -39, -113, 0, -78, 4, -23, -128, 9, -104, -20, -8, 66, 126});

But after loading the entity using Session.find()

user.getPasswordHash()

returns [29, -116, -39, -113, 0, -78, 4, -23, -128, 9, -104, -20, -8, 66, 126].
So the first byte is lost, the rest is OK!


I use 3.1a1 with annotations 3.1b3 with postgres 8.0.

Someone please help me in this one!!!

Br,
Norbi


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.