Changes for Checkstyle 8.32
[policy/models.git] / models-tosca / src / main / java / org / onap / policy / models / tosca / simple / concepts / JpaToscaModel.java
index a322c16..cc9b1bc 100644 (file)
@@ -1,6 +1,7 @@
 /*-
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2019 Nordix Foundation.
+ *  Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
 package org.onap.policy.models.tosca.simple.concepts;
 
 import java.util.List;
-
 import javax.persistence.CascadeType;
 import javax.persistence.Entity;
+import javax.persistence.FetchType;
 import javax.persistence.Inheritance;
 import javax.persistence.InheritanceType;
 import javax.persistence.OneToOne;
 import javax.persistence.Table;
-
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 import lombok.NonNull;
-
-import org.onap.policy.common.utils.validation.Assertions;
 import org.onap.policy.models.base.PfConcept;
 import org.onap.policy.models.base.PfConceptKey;
 import org.onap.policy.models.base.PfKey;
@@ -57,7 +55,7 @@ import org.onap.policy.models.base.PfValidationResult;
 public class JpaToscaModel extends PfModel {
     private static final long serialVersionUID = 8800599637708309945L;
 
-    @OneToOne(cascade = CascadeType.ALL)
+    @OneToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL, orphanRemoval = true)
     private JpaToscaServiceTemplates serviceTemplates;
 
     /**
@@ -96,6 +94,7 @@ public class JpaToscaModel extends PfModel {
      */
     public JpaToscaModel(@NonNull final JpaToscaModel copyConcept) {
         super(copyConcept);
+        this.serviceTemplates = new JpaToscaServiceTemplates(copyConcept.serviceTemplates);
     }
 
     @Override
@@ -136,7 +135,7 @@ public class JpaToscaModel extends PfModel {
         }
 
         if (getClass() != otherConcept.getClass()) {
-            return this.hashCode() - otherConcept.hashCode();
+            return getClass().getName().compareTo(otherConcept.getClass().getName());
         }
 
         final JpaToscaModel other = (JpaToscaModel) otherConcept;
@@ -146,15 +145,4 @@ public class JpaToscaModel extends PfModel {
 
         return serviceTemplates.compareTo(other.serviceTemplates);
     }
-
-    @Override
-    public PfConcept copyTo(@NonNull final PfConcept targetObject) {
-        Assertions.instanceOf(targetObject, JpaToscaModel.class);
-
-        final JpaToscaModel copy = ((JpaToscaModel) targetObject);
-        super.copyTo(targetObject);
-        copy.setServiceTemplates(new JpaToscaServiceTemplates(serviceTemplates));
-
-        return copy;
-    }
 }