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;
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` (
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"})
})
@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
+ @NotNull(message = "widgetId may not be null")
@Valid
private EpWidgetCatalog widgetId;
@Column(name = "status_cd", length = 1, nullable = false)
@Size(max = 1)
- @NotNull
- @SafeHtml
+ @NotNull(message = "status may not be null")
+ @SafeHtml(message = "status must be safeHtml")
private String statusCd;
}