Composite PK and @GeneratedValue

Description

[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).

Activity

Show:

Lukasz Antoniak August 14, 2011 at 6:55 PM

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

Helene Joanin July 2, 2009 at 7:26 PM

This bug seems to prevent to run the current version (june 2009, release 493) of the bench SpecJAppServer2008 on hibernate.

Duplicate

Details

Assignee

Reporter

Components

Priority

Created May 31, 2008 at 1:59 PM
Updated December 31, 2024 at 2:49 PM
Resolved December 31, 2024 at 2:49 PM