The following bug has been logged online:
Bug reference: 2708
Logged by: Shutra
Email address: zhoushuqun@gmail.com
PostgreSQL version: 8.1.5-1
Operating system: Windows or Linux
Description: Saving '\0' to bpchar by jdbc driver 8.1-407.jdbc3
Details:
Refer: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2161
<dependency>
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>8.1-407.jdbc3</version>
</dependency>
User user = new User();
user.setGender('M');
Transaction t = HibernateTest.getSessionFactory().getCurrentSession()
.beginTransaction();
HibernateTest.getSessionFactory().getCurrentSession().save(user);
t.commit(); //Saved OK.
user = new User();
user.setGender('\1');
t =
HibernateTest.getSessionFactory().getCurrentSession().beginTransaction();
HibernateTest.getSessionFactory().getCurrentSession().save(user);
t.commit(); // Also saved OK.
user = new User();
user.setGender('\0');
t =
HibernateTest.getSessionFactory().getCurrentSession().beginTransaction();
HibernateTest.getSessionFactory().getCurrentSession().save(user);
t.commit(); // Failed. That means the '\0' is not supported by the jdbc of
postgresql.
2006-10-20 15:44:23,638 DEBUG [org.hibernate.impl.SessionImpl] - opened
session at timestamp: 11613302636
2006-10-20 15:44:23,638 DEBUG [org.hibernate.transaction.JDBCTransaction] -
begin
2006-10-20 15:44:23,638 DEBUG [org.hibernate.jdbc.ConnectionManager] -
opening JDBC connection
2006-10-20 15:44:23,638 DEBUG [org.hibernate.transaction.JDBCTransaction] -
current autocommit status: false
2006-10-20 15:44:23,638 DEBUG
[org.hibernate.event.def.AbstractSaveEventListener] - generated identifier:
2c90c1710e64ad81010e64ad86560003, using strategy:
org.hibernate.id.UUIDHexGenerator
2006-10-20 15:44:23,653 DEBUG [org.hibernate.transaction.JDBCTransaction] -
commit
2006-10-20 15:44:23,653 DEBUG
[org.hibernate.event.def.AbstractFlushingEventListener] - processing
flush-time cascades
2006-10-20 15:44:23,653 DEBUG
[org.hibernate.event.def.AbstractFlushingEventListener] - dirty checking
collections
2006-10-20 15:44:23,653 DEBUG
[org.hibernate.event.def.AbstractFlushingEventListener] - Flushed: 1
insertions, 0 updates, 0 deletions to 1 objects
2006-10-20 15:44:23,653 DEBUG
[org.hibernate.event.def.AbstractFlushingEventListener] - Flushed: 0
(re)creations, 0 updates, 0 removals to 0 collections
2006-10-20 15:44:23,653 DEBUG [org.hibernate.pretty.Printer] - listing
entities:
2006-10-20 15:44:23,653 DEBUG [org.hibernate.pretty.Printer] -
test.hibernate.User{id=2c90c1710e64ad81010e64ad86560003, username=null,
gender=