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 io.hypersistence.utils.hibernate.type.json.JsonBinaryType;
25 import java.io.Serializable;
27 import javax.persistence.CascadeType;
28 import javax.persistence.Column;
29 import javax.persistence.Entity;
30 import javax.persistence.FetchType;
31 import javax.persistence.GeneratedValue;
32 import javax.persistence.GenerationType;
33 import javax.persistence.Id;
34 import javax.persistence.JoinColumn;
35 import javax.persistence.ManyToOne;
36 import javax.persistence.OneToMany;
37 import javax.persistence.OneToOne;
38 import javax.persistence.Table;
39 import javax.validation.constraints.NotNull;
40 import lombok.AllArgsConstructor;
41 import lombok.Builder;
43 import lombok.EqualsAndHashCode;
45 import lombok.NoArgsConstructor;
47 import lombok.ToString;
48 import org.hibernate.annotations.Type;
49 import org.hibernate.annotations.TypeDef;
52 * Entity to store a fragment.
61 @Table(name = "fragment")
62 @TypeDef(name = "jsonb", typeClass = JsonBinaryType.class)
63 @EqualsAndHashCode(onlyExplicitlyIncluded = true)
64 public class FragmentEntity implements Serializable {
66 private static final long serialVersionUID = 7737669789097119667L;
69 @GeneratedValue(strategy = GenerationType.IDENTITY)
73 @Column(columnDefinition = "text")
74 @EqualsAndHashCode.Include
77 @Column(name = "parent_id")
78 private Long parentId;
81 @Column(columnDefinition = "jsonb")
82 private String attributes;
85 @ManyToOne(fetch = FetchType.LAZY)
86 @JoinColumn(name = "dataspace_id")
87 private DataspaceEntity dataspace;
89 @OneToOne(fetch = FetchType.LAZY)
90 @JoinColumn(name = "anchor_id")
91 private AnchorEntity anchor;
94 @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.LAZY)
95 @JoinColumn(name = "parent_id")
96 private Set<FragmentEntity> childFragments;