Discriminator value used as ID when inserting entity to PosgtreSQL
------------------------------------------------------------------
Key: HHH-6580
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-6580
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.6.6, 3.6.5, 3.6.4, 3.6.3, 3.6.2, 3.6.1, 3.6.0
Environment: Tested on Hibernate 3.6.0, but I looked in the code of 3.6.6 and
4.0.0 Beta4 and it looks like it isn't fixed.
PostgreSQL 8.4.8
Reporter: Paweł Stawicki
When we have inheritance strategy SINGLE_TABLE, and we use discriminator column, this
column is the first one in table. Now we want to insert some entity inheriting from this
one, and we want PostgreSQL to automatically generate the ID for the new entity.
Discriminator column is the first in the table.
Hibernate runs IdentityGenerator.GetGeneratedKeysDelegate.executeAndExtract(), which gets
ResultSet from PreparedStatement (in Hibernate 3.6.0 it's line 97 in
IdentityGenerator).
This ResultSet, in case of PostgreSQL, contains whole inserted row, not only ID. This is
the problem if ID is not the first column, because then Hibernate get's value from the
first column and uses it as ID. It's in
IdentifierGeneratorHelper.getGeneratedIdentity() and IdentifierGeneratorHelper.get().
--
This message is automatically generated by JIRA.
For more information on JIRA, see:
http://www.atlassian.com/software/jira