001/*
002 * #%L
003 * HAPI FHIR JPA Server
004 * %%
005 * Copyright (C) 2014 - 2024 Smile CDR, Inc.
006 * %%
007 * Licensed under the Apache License, Version 2.0 (the "License");
008 * you may not use this file except in compliance with the License.
009 * You may obtain a copy of the License at
010 *
011 *      http://www.apache.org/licenses/LICENSE-2.0
012 *
013 * Unless required by applicable law or agreed to in writing, software
014 * distributed under the License is distributed on an "AS IS" BASIS,
015 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
016 * See the License for the specific language governing permissions and
017 * limitations under the License.
018 * #L%
019 */
020package ca.uhn.fhir.jpa.entity;
021
022import ca.uhn.fhir.jpa.model.entity.ResourceTable;
023import jakarta.persistence.Column;
024import jakarta.persistence.Entity;
025import jakarta.persistence.ForeignKey;
026import jakarta.persistence.GeneratedValue;
027import jakarta.persistence.GenerationType;
028import jakarta.persistence.Id;
029import jakarta.persistence.JoinColumn;
030import jakarta.persistence.OneToOne;
031import jakarta.persistence.SequenceGenerator;
032import jakarta.persistence.Table;
033import jakarta.persistence.Temporal;
034import jakarta.persistence.TemporalType;
035import jakarta.persistence.UniqueConstraint;
036
037import java.util.Date;
038
039@Entity
040@Table(
041                name = "HFJ_SUBSCRIPTION_STATS",
042                uniqueConstraints = {
043                        @UniqueConstraint(
044                                        name = "IDX_SUBSC_RESID",
045                                        columnNames = {"RES_ID"}),
046                })
047public class SubscriptionTable {
048
049        @Temporal(TemporalType.TIMESTAMP)
050        @Column(name = "CREATED_TIME", nullable = false, insertable = true, updatable = false)
051        private Date myCreated;
052
053        @Id
054        @GeneratedValue(strategy = GenerationType.AUTO, generator = "SEQ_SUBSCRIPTION_ID")
055        @SequenceGenerator(name = "SEQ_SUBSCRIPTION_ID", sequenceName = "SEQ_SUBSCRIPTION_ID")
056        @Column(name = "PID", insertable = false, updatable = false)
057        private Long myId;
058
059        @Column(name = "RES_ID", insertable = false, updatable = false)
060        private Long myResId;
061
062        @OneToOne()
063        @JoinColumn(
064                        name = "RES_ID",
065                        insertable = true,
066                        updatable = false,
067                        referencedColumnName = "RES_ID",
068                        foreignKey = @ForeignKey(name = "FK_SUBSC_RESOURCE_ID"))
069        private ResourceTable mySubscriptionResource;
070
071        /**
072         * Constructor
073         */
074        public SubscriptionTable() {
075                super();
076        }
077
078        public Date getCreated() {
079                return myCreated;
080        }
081
082        public void setCreated(Date theCreated) {
083                myCreated = theCreated;
084        }
085
086        public Long getId() {
087                return myId;
088        }
089
090        public ResourceTable getSubscriptionResource() {
091                return mySubscriptionResource;
092        }
093
094        public void setSubscriptionResource(ResourceTable theSubscriptionResource) {
095                mySubscriptionResource = theSubscriptionResource;
096        }
097}