如何获得可嵌入的更改?

时间:2018-12-14 11:00:20

标签: java hibernate spring-boot javers

我在春季启动时拥有一个带有嵌入式实体的实体。

现在,当我的嵌入式实体发生更改并且我向我的实体查询更改时,更改不在更改列表中。

@Entity
@Data
@AllArgsConstructor
@NoArgsConstructor
public class TaskEntity {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;
    @Embedded
    private LockSettingsEmbeddable lockSettings;
}

@Embeddable
@Data
@AllArgsConstructor
@NoArgsConstructor
public class LockSettingsEmbeddable {
    private boolean locked;
    @Enumerated(EnumType.STRING)
    private TaskLock lockSetting;
}

List<Change> changes = javers.findChanges(QueryBuilder.byInstanceId(taskId, TaskEntity.class).build());
        List<Change> modifiableList = new ArrayList<>(changes);
        modifiableList.sort((o1, o2) -> -1 * o1.getCommitMetadata().get().getCommitDate().compareTo(o2.getCommitMetadata().get().getCommitDate()));

        return javers.getJsonConverter().toJson(modifiableList);

1 个答案:

答案 0 :(得分:2)

只需启用withChildValueObject过滤器,请参见 https://javers.org/documentation/jql-examples/#child-value-objects-filter