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




Custom Search