001/*-
002 * #%L
003 * HAPI FHIR JPA Model
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.model.entity;
021
022import jakarta.annotation.Nullable;
023import jakarta.persistence.Column;
024import jakarta.persistence.Embedded;
025import jakarta.persistence.MappedSuperclass;
026
027import java.io.Serializable;
028
029/**
030 * This is the base class for entities with partitioning that does NOT include Hibernate Envers logging.
031 * <p>
032 * If your entity needs Envers auditing, please have it extend {@link AuditableBasePartitionable} instead.
033 */
034@MappedSuperclass
035public abstract class BasePartitionable implements Serializable {
036
037        @Embedded
038        private PartitionablePartitionId myPartitionId;
039
040        /**
041         * This is here to support queries only, do not set this field directly
042         */
043        @SuppressWarnings("unused")
044        @Column(name = PartitionablePartitionId.PARTITION_ID, insertable = false, updatable = false, nullable = true)
045        private Integer myPartitionIdValue;
046
047        @Nullable
048        public PartitionablePartitionId getPartitionId() {
049                return myPartitionId;
050        }
051
052        public void setPartitionId(PartitionablePartitionId thePartitionId) {
053                myPartitionId = thePartitionId;
054        }
055
056        @Override
057        public String toString() {
058                return "BasePartitionable{" + "myPartitionId="
059                                + myPartitionId + ", myPartitionIdValue="
060                                + myPartitionIdValue + '}';
061        }
062}