/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2020 Nordix Foundation. All rights reserved.
+ * Modifications Copyright (C) 2021 Pantheon.tech
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import lombok.Setter;
import org.hibernate.annotations.Type;
import org.hibernate.annotations.TypeDef;
-import org.hibernate.annotations.TypeDefs;
/**
* Entity to store a fragment.
@Builder
@Entity
@Table(name = "fragment")
-@TypeDefs({@TypeDef(name = "jsonb", typeClass = JsonBinaryType.class)})
+@TypeDef(name = "jsonb", typeClass = JsonBinaryType.class)
public class FragmentEntity implements Serializable {
private static final long serialVersionUID = 7737669789097119667L;
@JoinColumn(name = "anchor_id")
private AnchorEntity anchor;
- @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
+ @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.LAZY)
@JoinColumn(name = "parent_id")
private Set<FragmentEntity> childFragments;
}