Fix code smells
[cps.git] / cps-ri / src / main / java / org / onap / cps / spi / entities / FragmentEntity.java
index 6776528..74f75d1 100755 (executable)
@@ -1,6 +1,7 @@
 /*-
  * ============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.
@@ -44,7 +45,6 @@ import lombok.NoArgsConstructor;
 import lombok.Setter;
 import org.hibernate.annotations.Type;
 import org.hibernate.annotations.TypeDef;
-import org.hibernate.annotations.TypeDefs;
 
 /**
  * Entity to store a fragment.
@@ -57,7 +57,7 @@ import org.hibernate.annotations.TypeDefs;
 @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;
@@ -83,7 +83,7 @@ public class FragmentEntity implements Serializable {
     @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;
 }