Код: Выделить всё
@Entity
@IdClass(AId.class)
class A {
@Id
private String userName
@Id
@NotNull
@JoinColumn(name = "location_id", referenceColumnName = "id", nullable=false, foreignKey = @ForeignKey(name = ...))
private Location location;
private String userInformation;
}
Код: Выделить всё
@Entity
class Location {
@NotNull
private Long id;
@NotNull
@Column(nullable = false}
private String name;
}
Код: Выделить всё
class AId implements Serializable {
private Long locationId;
private String userName;
}
Подробнее здесь: https://stackoverflow.com/questions/792 ... lass-as-id
Мобильная версия