Hibernate 3.3.2GA incorrectly loads bytea data from PostgreSQL 9.0 and all type mappings are correct

You may have a bytea column displayed as a binary type of type Hibernate. In java, bytea data is appropriately represented as byte [].

When you install the data, it displays correctly in your PostreSQL 9.0 database.

For instance:

            set( [ 1, 2, 0, 1, 255, 0 ] )

Shows a regular SQL query as:

             \x010201ff00

When Hibernate calls your java set () program to load data, the data is incorrect. Everything except the first byte is replaced with an ASCII representation of the byte value. Breakpoint in the set () function and observe the Hibernate call with:

           set( [ 1, 50, 48, 49, 102, 102, 48 ] )

equivalently

           set( [ 1, '2', '0', '1', 'f, 'f', '0' ] )

PostgreSQL 9.0 changed its default output byte from "escape" to "hex". This confuses (at least) hibernation versions up to 9.0.

, postgresql.conf "bytea_output" "hex" "escape", . .

...
#vacuum_freeze_min_age = 50000000
#vacuum_freeze_table_age = 150000000
bytea_output = 'escape'         # hex, escape  escape is REQUIRED BY  HIBERNATE 3.3.2GA
#xmlbinary = 'base64'
#xmloption = 'content'
...

sql :

\001\002\000\001\377\000

hex , - , Hibernate 3.3.2GA, ?

+3
1

Hibernate , PostgreSQL JDBC, . , , , DBD:: Pg Perl.

​​ PostgreSQL JDBC , . .: http://jdbc.postgresql.org/changes.html#version_9.0-dev800

+6

Source: https://habr.com/ru/post/1789370/


All Articles