在 Spring Boot 应用程序中,我有一个复合 id 定义如下的类:
@Embeddable
public class StatisticId implements Serializable {
private static final long serialVersionUID = 1L;
@Column(length = 255, nullable = false)
private String shortName;
@Enumerated(EnumType.STRING)
@Column(length = 32, nullable = false)
private Month month;
@Column(nullable = false)
private int year;
// getters, setters, equals, hashCode, toString
}
Run Code Online (Sandbox Code Playgroud)
(简化的)类定义是:
@Entity
public class Statistic implements Serializable {
private static final long serialVersionUID = 1L;
private BigDecimal sales;
@EmbeddedId
private StatisticId id;
// getters, setters, toString
}
Run Code Online (Sandbox Code Playgroud)
我想对这门课进行投影: …