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

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

import org.hibernate.annotations.Comment;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.envers.RevisionEntity;
import org.hibernate.envers.RevisionNumber;
import org.hibernate.envers.RevisionTimestamp;

import lombok.Data;

@Data

@Entity
@Table(name = "REVINFO")
@RevisionEntity(CustomRevisionListener.class)
@SequenceGenerator(name = "revision_seq", sequenceName = "revision_info_seq", allocationSize = 1)
public class CustomRevisionEntity {

	@Id
//	@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "revision_seq")
	@GenericGenerator(
			name = "revision_seq_gen",
			strategy = "com.eactive.eai.rms.data.jpa.SchemaPrefixedSequenceGenerator",
			parameters = {
					@org.hibernate.annotations.Parameter(name = "sequence_name", value = "REVISION_INFO_SEQ"),
					@org.hibernate.annotations.Parameter(name = "initial_value", value = "1"),
					@org.hibernate.annotations.Parameter(name = "increment_size", value = "1")
			}
	)
	@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "revision_seq_gen")
	@RevisionNumber
	@Column(name = "REV")
	private long rev;

	@RevisionTimestamp
	@Column(name = "REVTSTMP")
	@Comment("revision생성날짜")
	private long revTstmp;

	@Column(name = "USERID")
	@Comment("변경자ID")
	private String userId;
}