我有三个相关的课程如下:
@AllArgsConstructor
@NoArgsConstructor
@ToString(callSuper = true)
@Getter
@Setter
@Entity
public class Job implements Serializable {
@Id
@Column(name = "JOB_ID")
private String jobId;
@OneToMany(fetch = FetchType.EAGER, orphanRemoval = true, cascade = CascadeType.REFRESH)
private List<Task> tasks;
}
@NoArgsConstructor
@ToString(callSuper = true)
@Getter
@Setter
@Entity
@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "taskId", scope = Task.class)
public class Task implements Serializable {
@Id
@Column(name = "TASK_ID")
private String taskId;
@Embedded
private DockerEnvironment environment;
}
和/或
@AllArgsConstructor
@NoArgsConstructor
@ToString(callSuper = true)
@Getter
@Setter
@Embeddable
@JsonTypeName(value = "docker")
public class DockerEnvironment extends AbstractInstallation {
@Column(name = "DOCKER_IMAGE")
private String dockerImage;
@Column(name = "PORT")
@JsonProperty("port")
private String port;
@ElementCollection
@CollectionTable(name = "DOCKER_ENV_VARS_MAPPING", joinColumns = { @JoinColumn(name = "DOCKER_TASK_ID") })
@MapKeyColumn(name = "ENVVAR_KEY")
@Column(name = "ENVVAR_VALUE")
private Map<String, String> environmentVars;
}
我发送一个REST请求来创建一个带有以下JSON部分的作业:
.
.
.
"tasks": [{
"installation": {
"environmentVars": {
"MYSQL_DATABASE": "NAME",
"MYSQL_USER": "USER",
"MYSQL_ROOT_PASSWORD": "admin"
}
.
.
.
在我的代码中的某个时刻,我手动保存新创建的对象,方法是:
repositoryService.saveTask(newTask);
repositoryService.saveJob(newJob);
repositoryService.flush();
在调试时,我看到一切正常,但在DB environmentVars
表(DOCKER_ENV_VARS
)为空之后。请问有什么问题吗?
1条答案
按热度按时间hc8w905p1#
尝试从AbstractInstallation中删除扩展并查看问题是否仍然存在