Java Reference
In-Depth Information
Listing 6-8. Using the @IdClass and @Id Annotations to Map a Compound Primary Key
package com.hibernatebook.annotations;
import javax.persistence.*;
@Entity
@IdClass(Account.AccountPk.class)
public class Account {
private String description;
private String code;
private Integer number;
public Account(String description) {
this.description = description;
}
protected Account() {
}
@Id
public String getCode() {
return this.code;
}
@Id
public Integer getNumber() {
return this.number;
}
public String getDescription() {
return this.description;
}
public void setDescription(String description) {
this.description = description;
}
public void setNumber(Integer number) {
this.number = number;
}
public void setCode(String code) {
this.code = code;
}
Search WWH ::




Custom Search