TaxonomySpeciesSynonymMap.java

/*
 * Copyright 2023 Global Crop Diversity Trust
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.gringlobal.model;

import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import static org.gringlobal.model.community.CommunityCodeValues.CODE_VALUE_LENGTH;

import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

@Entity
@Table(name = "taxonomy_species_synonym_map")
@Getter
@Setter
@NoArgsConstructor
public class TaxonomySpeciesSynonymMap extends CooperatorOwnedModel {

	private static final long serialVersionUID = 6608516809526812642L;

	@Id
	@Column(name = "taxonomy_species_synonym_map_id", columnDefinition = "int")
	private Long id;

	@Basic
	@Column(name = "synonym_code", columnDefinition = "nvarchar", nullable = false, length = CODE_VALUE_LENGTH)
	private String synonymCode;

	@ManyToOne(fetch = FetchType.LAZY, cascade = {})
	@JoinColumn(name = "taxona_taxonomy_species_id", nullable = false)
	private TaxonomySpecies taxonaTaxonomySpecies;

	@ManyToOne(fetch = FetchType.LAZY, cascade = {})
	@JoinColumn(name = "taxonb_taxonomy_species_id", nullable = false)
	private TaxonomySpecies taxonbTaxonomySpecies;

	@Basic
	@Column
	@Lob
	private String note;

	public TaxonomySpeciesSynonymMap(Long id) {
		this.id = id;
	}

	@Override
	public boolean canEqual(Object other) {
		return other instanceof TaxonomySpeciesSynonymMap;
	}
}