Spring Boot 不会在 ItemMedium 实体中返回任何内容

问题描述 投票:0回答:1

我正在尝试获取具有以下属性的 ItemMedium 表的内容(item_id 和medium_id 是 Item 和 Medium 表中的外键)。

@Entity(name = "ITEM_MEDIUM")
@RequiredArgsConstructor
@AllArgsConstructor
@Setter
@Getter
public class ItemMedium {
    @Id
    @JsonProperty("ITEM_MEDIUM_ID")
    @GeneratedValue(generator = "ITEM_MEDIUM_SEQ")
    @SequenceGenerator(name="ITEM_MEDIUM_SEQ", sequenceName = "ITEM_MEDIUM_SEQ", allocationSize = 1)
    private Long itemMediumId;
    @JsonProperty("ITEM_ID")
    private Long itemId;
    @JsonProperty("MEDIUM_ID")
    private Long mediumId;
    @JsonProperty("ARCHIVE_STATUS")
    private String archiveStatus;
    @JsonProperty("TYPE")
    private String type;
    @JsonProperty("STATUS")
    private String status;
    @JsonProperty("QUANTITY")
    private Long quantity;
    @JsonProperty("START_CONSUMPTION_DATE")
    private Date startConsumptionDate;
    @JsonProperty("END_CONSUMPTION_DATE")
    private Date endConsumptionDate;
    @JsonProperty("CREATE_DATE")
    private Date createDate;
    @JsonProperty("LAST_MODIFIED")
    private Date lastModified;
}

但是,当我尝试获取存储库中的所有内容并且 Postman 显示一个空数组时,它不会返回任何内容。我做错了什么?

java spring spring-boot jpa spring-data-jpa
1个回答
0
投票

需要注释表之间的关系。

@ManyToOne or @OneToMany or @OneToOne

© www.soinside.com 2019 - 2024. All rights reserved.