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
|