[hibernate-issues] [Hibernate-JIRA] Updated: (HHH-6580) Discriminator value used as ID when inserting entity to PosgtreSQL

Paweł Stawicki (JIRA) noreply at atlassian.com
Wed Aug 17 17:48:03 EDT 2011


     [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-6580?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Paweł Stawicki updated HHH-6580:
--------------------------------

    Attachment: amorfis-Hibernate-postgreSQL-bug-3ef4fb0.zip

Test case for the issue. Just unzip and issue {{mvn test}}. Also available at https://github.com/amorfis/Hibernate-postgreSQL-bug

> 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.0, 3.6.1, 3.6.2, 3.6.3, 3.6.4, 3.6.5, 3.6.6
>         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
>              Labels: generated
>         Attachments: amorfis-Hibernate-postgreSQL-bug-3ef4fb0.zip
>
>
> 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

       



More information about the hibernate-issues mailing list