package com.eactive.eai.rms.data.entity.onl.code;

import java.io.Serializable;
import java.util.List;

import javax.persistence.Cacheable;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.OrderBy;
import javax.persistence.Table;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.Comment;

import com.eactive.eai.data.entity.AbstractEntity;

import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NonNull;
import lombok.ToString;

@Data
@EqualsAndHashCode(onlyExplicitlyIncluded = true, callSuper = true)

@Entity
@Table(name = "tseaicm19")
@org.hibernate.annotations.Table(appliesTo = "tseaicm19", comment = "코드그룹 정보")
@Cacheable
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class CodeGroup extends AbstractEntity<String> implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	@Column(unique = true, nullable = false, length = 50)
	@Comment("코드 그룹")
	private String codegroup;

	@Column(length = 1000)
	@Comment("그룹 설명")
	private String description;

	@Override
	public @NonNull String getId() {
		return codegroup;
	}

	@OneToMany(mappedBy = "codegroups", cascade = CascadeType.ALL, orphanRemoval = true)
	@ToString.Exclude
	@OrderBy("id.code ASC")
	@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
	private List<Code> codes;
}