History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: ANN-435
Type: Bug Bug
Status: Resolved Resolved
Resolution: Duplicate
Priority: Major Major
Assignee: Diego Plentz
Reporter: Patrick Moore
Votes: 2
Watchers: 2
Operations

If you were logged in you would be able to see more operations.
Hibernate Annotations

multiple @Id attributes not handled correctly

Created: 07/Sep/06 08:32 PM   Updated: 02/Nov/07 07:47 PM
Component/s: binder
Affects Version/s: 3.2.0.cr1
Fix Version/s: None

Time Tracking:
Not Specified

Environment: hibernate 3.2.0.cr2 hsql 1.8.0.4
Issue Links:
Duplicate
 
Relates
 


 Description  « Hide
Defining a class with 2 @Id annotations should report a error or it should work. Instead only the first field with the @Id attribute is marked as a primary key but both are marked as nonnull.

For example:

public class IdUsing2 {
    @Id
    public Integer databaseId;
    @Id @GeneratedValue
    public Long entityId;
}

results in this SQL:
18:26:57,765 DEBUG [SchemaExport] create table IdUsing2 (entityId bigint not null, databaseId integer not null, idl bigint, value varchar(255), primary key (databaseId))

and no warning or error message.


 All   Comments   Work Log   Change History   FishEye      Sort Order: Ascending order - Click to sort in descending order
Patrick Moore - 07/Sep/06 08:34 PM
(I keep doing this) class looks like this:
@Entity
public class IdUsing2 {
    @Id
    public Integer databaseId;
    @Id @GeneratedValue
    public Long entityId;


    public Long idl;
    public String value;
    
}