001package ca.uhn.fhir.jpa.model.entity;
002
003/*-
004 * #%L
005 * HAPI FHIR JPA Model
006 * %%
007 * Copyright (C) 2014 - 2024 Smile CDR, Inc.
008 * %%
009 * Licensed under the Apache License, Version 2.0 (the "License");
010 * you may not use this file except in compliance with the License.
011 * You may obtain a copy of the License at
012 *
013 *      http://www.apache.org/licenses/LICENSE-2.0
014 *
015 * Unless required by applicable law or agreed to in writing, software
016 * distributed under the License is distributed on an "AS IS" BASIS,
017 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
018 * See the License for the specific language governing permissions and
019 * limitations under the License.
020 * #L%
021 */
022
023import jakarta.annotation.Nullable;
024import jakarta.persistence.Column;
025import jakarta.persistence.Embedded;
026import jakarta.persistence.MappedSuperclass;
027import org.hibernate.envers.Audited;
028import org.hibernate.envers.NotAudited;
029
030import java.io.Serializable;
031
032/**
033 * This is a copy of (@link {@link BasePartitionable} used ONLY for entities that are audited by Hibernate Envers.
034 * <p>
035 * The reason for this is Envers will generate _AUD table schema for all auditable tables, even those marked as {@link NotAudited}.
036 * <p>
037 * Should we make more entities envers auditable in the future, they would need to extend this class and not {@link BasePartitionable}.
038 */
039@Audited
040@MappedSuperclass
041public class AuditableBasePartitionable implements Serializable {
042        @Embedded
043        private PartitionablePartitionId myPartitionId;
044
045        /**
046         * This is here to support queries only, do not set this field directly
047         */
048        @SuppressWarnings("unused")
049        @Column(name = PartitionablePartitionId.PARTITION_ID, insertable = false, updatable = false, nullable = true)
050        private Integer myPartitionIdValue;
051
052        @Nullable
053        public PartitionablePartitionId getPartitionId() {
054                return myPartitionId;
055        }
056
057        public void setPartitionId(PartitionablePartitionId thePartitionId) {
058                myPartitionId = thePartitionId;
059        }
060}