|
| 1 | +/* |
| 2 | + * SPDX-License-Identifier: Apache-2.0 |
| 3 | + * SPDX-FileCopyrightText: Huawei Inc. |
| 4 | + * |
| 5 | + */ |
| 6 | + |
| 7 | +package org.eclipse.xpanse.modules.database.serviceobject; |
| 8 | + |
| 9 | +import io.hypersistence.utils.hibernate.type.json.JsonType; |
| 10 | +import jakarta.persistence.CollectionTable; |
| 11 | +import jakarta.persistence.Column; |
| 12 | +import jakarta.persistence.Convert; |
| 13 | +import jakarta.persistence.ElementCollection; |
| 14 | +import jakarta.persistence.Entity; |
| 15 | +import jakarta.persistence.FetchType; |
| 16 | +import jakarta.persistence.GeneratedValue; |
| 17 | +import jakarta.persistence.GenerationType; |
| 18 | +import jakarta.persistence.Id; |
| 19 | +import jakarta.persistence.JoinColumn; |
| 20 | +import jakarta.persistence.OneToOne; |
| 21 | +import jakarta.persistence.Table; |
| 22 | +import java.io.Serial; |
| 23 | +import java.io.Serializable; |
| 24 | +import java.util.Map; |
| 25 | +import java.util.Set; |
| 26 | +import java.util.UUID; |
| 27 | +import lombok.Data; |
| 28 | +import org.eclipse.xpanse.modules.database.common.ObjectJsonConverter; |
| 29 | +import org.eclipse.xpanse.modules.database.service.ServiceDeploymentEntity; |
| 30 | +import org.eclipse.xpanse.modules.models.servicetemplate.ObjectIdentifier; |
| 31 | +import org.hibernate.annotations.Type; |
| 32 | + |
| 33 | +/** ServiceObjectEntity for persistence. */ |
| 34 | +@Table(name = "SERVICE_OBJECT") |
| 35 | +@Entity |
| 36 | +@Data |
| 37 | +public class ServiceObjectEntity implements Serializable { |
| 38 | + |
| 39 | + @Serial private static final long serialVersionUID = 8759122775257853274L; |
| 40 | + |
| 41 | + @Id |
| 42 | + @GeneratedValue(strategy = GenerationType.UUID) |
| 43 | + @Column(name = "OBJECT_ID", nullable = false) |
| 44 | + private UUID objectId; |
| 45 | + |
| 46 | + @OneToOne(fetch = FetchType.LAZY) |
| 47 | + @JoinColumn(name = "SERVICE_ID", nullable = false) |
| 48 | + private ServiceDeploymentEntity serviceDeploymentEntity; |
| 49 | + |
| 50 | + @JoinColumn(name = "OBJECT_TYPE", nullable = false) |
| 51 | + private String objectType; |
| 52 | + |
| 53 | + @JoinColumn(name = "OBJECT_IDENTIFIER", nullable = false) |
| 54 | + private ObjectIdentifier objectIdentifier; |
| 55 | + |
| 56 | + @Column(name = "PROPERTIES", columnDefinition = "json", length = Integer.MAX_VALUE) |
| 57 | + @Type(value = JsonType.class) |
| 58 | + @Convert(converter = ObjectJsonConverter.class) |
| 59 | + private Map<String, Object> properties; |
| 60 | + |
| 61 | + @ElementCollection |
| 62 | + @CollectionTable( |
| 63 | + name = "SERVICE_DEPENDENT_OBJECT", |
| 64 | + joinColumns = @JoinColumn(name = "OBJECT_ID", nullable = false) // 当前对象ID |
| 65 | + ) |
| 66 | + @Column(name = "DEPENDENT_OBJECT_ID") |
| 67 | + private Set<UUID> dependentObjectIds; |
| 68 | +} |
0 commit comments