我有一张表,其中的主键是所有列的组合键(不要问我为什么:(。我为它创建了一个实体,如下所示。当我尝试使用Spring数据JPA来获取数据时,它什么也不会返回。但是从日志中,我可以看到hibernate运行了查询并且也获取了数据。请告知我我在做什么错。
@Entity
@Getter
@Setter
@NoArgsConstructor
@Table(name = "PORTAL_CSV_HEADERS")
public class PortalCsvHeaders implements Serializable {
@EmbeddedId
@AttributeOverrides({
@AttributeOverride(
name = "orderId",
column = @Column(name = "ORDER_ID", nullable = false, precision = 9, scale = 0)),
@AttributeOverride(
name = "csvHeaderName",
column = @Column(name = "CSV_HEADER_NAME", length = 100)),
@AttributeOverride(
name = "recipientMapId",
column = @Column(name = "RECIPIENT_MAP_ID", precision = 22, scale = 0)),
@AttributeOverride(
name = "recipientDlfVal",
column = @Column(name = "RECIPIENT_DLF_VAL", length = 100)),
@AttributeOverride(
name = "recipientDlfName",
column = @Column(name = "RECIPIENT_DLF_NAME", length = 200))
})
private PortalCsvHeadersId id;
@JsonIgnore
@ManyToOne
@JoinColumn(name = "ORDER_ID", insertable = false, updatable = false)
private PortalOrder order;
这是PortalCsvHeadersId
@Data
@Embeddable
@NoArgsConstructor
public class PortalCsvHeadersId implements Serializable {
@Column(name = "ORDER_ID", nullable = false, precision = 9, scale = 0)
private Long orderId;
@Column(name = "CSV_HEADER_NAME", length = 100)
private String csvHeaderName;
@Column(name = "RECIPIENT_MAP_ID", precision = 22, scale = 0)
private Long recipientMapId;
@Column(name = "RECIPIENT_DLF_VAL", length = 100)
private String recipientDlfVal;
@Column(name = "RECIPIENT_DLF_NAME", length = 200)
private String recipientDlfName;
}
这是PortalOrder中的关联
@OneToMany(cascade = CascadeType.ALL, mappedBy = "order", orphanRemoval = true)
private Set<PortalCsvHeaders> portalCsvHeaders = new HashSet<PortalCsvHeaders>(0);