[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-4159) Composite PK and @GeneratedValue

Lukasz Antoniak (JIRA) noreply at atlassian.com
Sun Aug 14 12:57:04 EDT 2011


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-4159?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=43232#comment-43232 ] 

Lukasz Antoniak commented on HHH-4159:
--------------------------------------

This seems to work in the 4.x branch (build on 14/08/2011).

> Composite PK and @GeneratedValue
> --------------------------------
>
>                 Key: HHH-4159
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-4159
>             Project: Hibernate Core
>          Issue Type: Bug
>          Components: entity-manager
>         Environment: Hibernate 3.2.6
> Glassfish
> PostgreSQL
>            Reporter: Radosław Smogura
>            Priority: Critical
>
> [code]
> For class like this
> @Entity
> @IdClass(FooId.class)
> /* Seq / Table generator */
> public class Foo {
>   int id1;
>  int id2;
> @Id
> public getId1() {
> return id1;
> }
> public setId1(....);
> @Id
> @GeneratedValue(strategy=AUTO/IDENTITY/SEQUENCE/TABLE)
> public int getId2() {
> return id2;
> }
> public void setId2(.....);
> }
> [/code]
> Id1 is set manully, but id2 is unchanged i this situation hibernate doesn't generates PK and tries to insert NULL  causing error.
> Specification requires assigning of generated value with @Id properties. Part 2.4.1 defines two types of PKs simple and composite and part 9.1.9 says about PKs in generally.  (SEQ or IDENTITY is specification depended, but PostgreSQL support it and Hibernate should support it too).

--
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