For a composite-id of a legacy database I took the "annotate the component property as @Id and make the component class @Embeddable" approach.
However MS SQLServer complaints:
Code:
Unsuccessful: create table Dog(house int null, person int null, primary key (house, person))
Cannot define PRIMARY KEY constraint on nullable column in table
It's clear the create table should contain "house int
not null", because my code has a @NotNull.
Here's the code:
Code:
@Embeddable
public class DogId implements Serializable {
private House house;
private Person person;
@ManyToOne(fetch = FetchType.EAGER)
@NotNull
@JoinColumn(name = "house")
public House getHouse() {
return house;
}
...
}
Code:
@Entity
public class Dog extends ComparablePersistable {
DogId id;
@Id
@NotNull
public DogId getId() {
return id;
}
public void setId(DogId id) {
this.id = id;
}
...
}
I am using 3.2.0.ga. Is there a JIRA for this?[/b][/code]