Domain model change
[portal.git] / portal-BE / src / main / java / org / onap / portal / domain / db / ep / EpPersUserWidgetSel.java
index 6c439c8..2d4c76f 100644 (file)
 
 package org.onap.portal.domain.db.ep;
 
+import java.io.Serializable;
 import javax.persistence.CascadeType;
 import javax.persistence.Column;
 import javax.persistence.Entity;
 import javax.persistence.FetchType;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
 import javax.persistence.JoinColumn;
 import javax.persistence.ManyToOne;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
 import javax.persistence.Table;
 import javax.persistence.UniqueConstraint;
 import javax.validation.Valid;
-import javax.validation.constraints.Digits;
 import javax.validation.constraints.NotNull;
 import javax.validation.constraints.Size;
 import lombok.AllArgsConstructor;
@@ -61,6 +60,7 @@ import lombok.NoArgsConstructor;
 import lombok.Setter;
 import org.hibernate.validator.constraints.SafeHtml;
 import org.onap.portal.domain.db.fn.FnUser;
+import org.onap.portal.domain.db.DomainVo;
 
 /*
 CREATE TABLE `ep_pers_user_widget_sel` (
@@ -75,7 +75,11 @@ CREATE TABLE `ep_pers_user_widget_sel` (
         CONSTRAINT `fk_2_ep_pers_user_wid_sel_ep_wid` FOREIGN KEY (`widget_id`) REFERENCES `ep_widget_catalog` (`widget_id`)
         )
 */
-
+@NamedQueries({
+        @NamedQuery(
+                name = "EpPersUserWidgetSel.getEpPersUserWidgetSelForUserIdAndWidgetId",
+                query = "FROM EpPersUserWidgetSel WHERE userId.id = :USERID and widgetId.widgetId = :WIDGETID")
+})
 @Table(name = "ep_pers_user_widget_sel", uniqueConstraints = {
         @UniqueConstraint(columnNames = {"user_id", "widget_id"})
 })
@@ -84,18 +88,14 @@ CREATE TABLE `ep_pers_user_widget_sel` (
 @Getter
 @Setter
 @Entity
-public class EpPersUserWidgetSel {
-       @Id
-       @GeneratedValue(strategy = GenerationType.AUTO)
-       @Column(name = "id", length = 11, nullable = false)
-       @Digits(integer = 11, fraction = 0)
-       private Long id;
-       @ManyToOne(fetch = FetchType.LAZY,cascade = CascadeType.ALL)
-       @JoinColumn(name = "user_id", nullable = false)
+public class EpPersUserWidgetSel extends DomainVo implements Serializable {
+
+       @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.MERGE)
+       @JoinColumn(name = "user_id", nullable = false, columnDefinition = "bigint")
        @NotNull
        @Valid
        private FnUser userId;
-       @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
+       @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.MERGE)
        @JoinColumn(name = "widget_id", nullable = false)
        @NotNull
        @Valid