我是Spring Data Rest的新手。我想和他的孩子一起保存一个父实体。该类是Distribution和FileIdVersion。
这是分发实体。
@Entity
@DistributionValidator
public class Distribution extends AbstractAuditableJpaEntityImpl {
private static final long serialVersionUID = 1L;
@NotNull
@Length(min = 1, max = 256)
@SafeHtml
private String company;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "distribution")
@Size(max = 256)
private List<FileIdVersion> fileIdVersions = new ArrayList<>();
public Distribution() {
super();
}
public Distribution(final String company, final String name, final String topic, final ZonedDateTime uploadDate,
final ZonedDateTime setupDate, final UUID uuid, final List<FileIdVersion> fileIdVersions,
final List<Bundle> bundles, final List<String> recipientId) {
super();
this.company = company;
this.fileIdVersions = fileIdVersions;
}
}
这是FileIdVersion实体。
@Entity(name = "bundle_file_id_version")
public class FileIdVersion extends AbstractJpaEntityImpl implements Serializable {
private static final long serialVersionUID = 1L;
@NotNull
@FileId
private String fileId;
@FileVersion
private String fileVersion;
@ManyToOne
@NotNull
@JsonIgnore
private Bundle bundle;
public FileIdVersion() {}
}
我想用他的fileIdVersion保存一个分发对象。我正在尝试这样的事情:
该请求仅在BBDD分发的一个记录中保留,而在FileIdVersion实体中不保留任何记录。我该如何使用他的文件ID版本来保持分发?预先谢谢你!