2

I am using Hibernate 3.6 on two different boxes, both reading from exactly the same database table. The Hibernate annotation for two fields is as such:

@Basic(fetch=FetchType.EAGER)
@Column(name="encryptedkey",length = 256)
protected byte[] encryptedKey;

@Basic(fetch=FetchType.EAGER)
@Column(name="encryptediv",length = 256)
protected byte[] encryptedIV;

Now, when loading the entity with those properties on one machine (Ubuntu Linux with Sun JDK 1.6.0_22-b04), I am able to load the 256-byte encrypted keys and IVs.

However, it is not the case on another machine (Windows 2003 server SP2 Enterprise Edition with Sun JVM 1.6.0_22-b04), I have either 0 or 511 bytes loaded for each field. Otherwise, the Jar files on both systems are the same.

The database engine is PostgreSQL 9.0 and I'm using the latest PostgreSQL JDBC driver.

Anyone has any idea what could be going wrong?

6
  • the postgre column type is array? Commented Dec 2, 2010 at 12:51
  • The type in postgre is bytea Commented Dec 3, 2010 at 4:28
  • Some troubleshooting steps tried: upgraded JVM, upgraded Hibernate 1.6 libs, downgraded to Hibernate 3.3.2, changed from infinispan to ehcache. I also tried with the JDBC3 and JDBC4 drivers with the same results. None of these things changed anything. Commented Dec 3, 2010 at 7:32
  • I'd try running it in a debugger and setting a breakpoint in the nullSafeGet() method of whichever Hibernate Type implementation is handling these... see if what's coming back from the JDBC driver is sane or not, so you can at least tell if it's a Hibernate or JDBC driver problem. You might also find out that the Type being used isn't what you expect or want. Commented Dec 4, 2010 at 4:51
  • maybe that should have been an answer? but it doesn't really answer anything... Commented Dec 4, 2010 at 4:51

2 Answers 2

2

It turns out that the JRE lib folder had a PosgreSQL 8.4 driver in it. Deleting it solved that issue.

Sign up to request clarification or add additional context in comments.

2 Comments

probably due to the bytea escape format changing, then. setting bytea_output to "escape" on the server would work around that too, in case you have to do this again somewhere you can't fiddle with the JRE.
Good point. If that driver can't be deleted, then the escaping done by the driver will have to be undone. Big performance hit.
0

definitive solution:

ALTER DATABASE myAmazingDbOnALinuxServer SET bytea_output = 'escape'; 

PD: this variable may the backups incompatibles with Postgre installed on Windows, will throw a COPY error for each row of the tables that contains a bytea column.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.