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;
028import java.time.LocalDate;
029
030/**
031 * This is the base class for entities with partitioning that does NOT include Hibernate Envers logging.
032 * <p>
033 * If your entity needs Envers auditing, please have it extend {@link AuditableBasePartitionable} instead.
034 */
035@MappedSuperclass
036public abstract class BasePartitionable implements Serializable {
037
038        @Embedded
039        private PartitionablePartitionId myPartitionId;
040
041        /**
042         * This is here to support queries only, do not set this field directly
043         */
044        @SuppressWarnings("unused")
045        @Column(name = PartitionablePartitionId.PARTITION_ID, insertable = false, updatable = false, nullable = true)
046        private Integer myPartitionIdValue;
047
048        /**
049         * This is here to support queries only, do not set this field directly
050         */
051        @SuppressWarnings("unused")
052        @Column(name = PartitionablePartitionId.PARTITION_DATE, insertable = false, updatable = false, nullable = true)
053        private LocalDate myPartitionDateValue;
054
055        @Nullable
056        public PartitionablePartitionId getPartitionId() {
057                return myPartitionId;
058        }
059
060        public void setPartitionId(PartitionablePartitionId thePartitionId) {
061                myPartitionId = thePartitionId;
062        }
063
064        @Override
065        public String toString() {
066                return "BasePartitionable{" + "myPartitionId="
067                                + myPartitionId + ", myPartitionIdValue="
068                                + myPartitionIdValue + ", myPartitionDateValue="
069                                + myPartitionDateValue + '}';
070        }
071}