小编pan*_*tus的帖子

投影对象上字符串字段的空值

在 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)

我想对这门课进行投影: …

java mysql jpa spring-boot

1
推荐指数
1
解决办法
839
查看次数

标签 统计

java ×1

jpa ×1

mysql ×1

spring-boot ×1