2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2020-2023 Nordix Foundation.
4 * Modifications Copyright (C) 2021 Pantheon.tech
5 * ================================================================================
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
18 * SPDX-License-Identifier: Apache-2.0
19 * ============LICENSE_END=========================================================
22 package org.onap.cps.spi.entities;
24 import jakarta.persistence.CascadeType;
25 import jakarta.persistence.Column;
26 import jakarta.persistence.Entity;
27 import jakarta.persistence.FetchType;
28 import jakarta.persistence.GeneratedValue;
29 import jakarta.persistence.GenerationType;
30 import jakarta.persistence.Id;
31 import jakarta.persistence.JoinColumn;
32 import jakarta.persistence.ManyToOne;
33 import jakarta.persistence.OneToMany;
34 import jakarta.persistence.Table;
35 import jakarta.validation.constraints.NotNull;
36 import java.io.Serializable;
38 import lombok.AllArgsConstructor;
39 import lombok.Builder;
41 import lombok.EqualsAndHashCode;
43 import lombok.NoArgsConstructor;
45 import lombok.ToString;
46 import org.hibernate.annotations.JdbcTypeCode;
47 import org.hibernate.type.SqlTypes;
50 * Entity to store a fragment.
59 @Table(name = "fragment")
60 @EqualsAndHashCode(onlyExplicitlyIncluded = true)
61 public class FragmentEntity implements Serializable {
63 private static final long serialVersionUID = 7737669789097119667L;
66 @GeneratedValue(strategy = GenerationType.IDENTITY)
70 @Column(columnDefinition = "text")
71 @EqualsAndHashCode.Include
74 @Column(name = "parent_id")
75 private Long parentId;
77 @JdbcTypeCode(SqlTypes.JSON)
78 @Column(columnDefinition = "jsonb")
79 private String attributes;
82 @ManyToOne(fetch = FetchType.LAZY)
83 @JoinColumn(name = "anchor_id")
84 @EqualsAndHashCode.Include
85 private AnchorEntity anchor;
88 @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.LAZY)
89 @JoinColumn(name = "parent_id")
90 private Set<FragmentEntity> childFragments;