Valahogy így:
@Embeddable
public class AccountId {
private String accountNumber;
private String accountType;
...
}
@Entity
public class Account {
@EmbeddedId
@AttributeOverrides({
@AttributeOverride(name="accountNumber", column=@Column(name="account_number")),
@AttributeOverride(name="accountType", column=@Column(name="account_type"))
})
private AccountId id;
...
}
az @AttributeOverrides szekciót azért tettem bele, mert ezzel pontosan el tudod nevezni a DB mezőket. A hibernatenek van olyan NamingStrategy-je (jpa/component-path), hogy hajlamos elécsapni a generált neveknek prefixként azt, hogy "id_"
[ Szerkesztve ]