package com.bytesw.bytebot.model;

import com.bytesw.xdf.model.converter.BooleanToStringConverter;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.hibernate.envers.Audited;

import javax.persistence.*;
import java.io.Serializable;
import java.math.BigInteger;

@Audited
@Entity
@Table(name = "AVB_BUSINESS_PARAMETER")
@NamedQuery(name = "BusinessParameter.findByPK", query = "Select u from BusinessParameter u where u.id = ?1")
@Getter @Setter
@EqualsAndHashCode
@ToString(exclude = "id")
public class BusinessParameter implements Serializable {

    @Id
    @Column(name = "BUPA_ID")
    @SequenceGenerator(name = "AVB_BUSINESS_PARAMETER_GENERATOR", sequenceName = "AVB_BUSINESS_PARAMETER_SEQ", initialValue = 1, allocationSize = 1)
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "AVB_BUSINESS_PARAMETER_GENERATOR")
    private BigInteger id;

    @Version
    @Column(name = "VERSION")
    @Basic(optional = false)
    private long version;

    @Column(name = "BUPA_KEY", nullable = false, unique = true)
    private String key;

    @Column(name = "BUPA_DESCR", nullable = false)
    private String description;

    @Column(name = "BUPA_REQUI", nullable = false)
    @Convert(converter = BooleanToStringConverter.class)
    private Boolean required;

    @Column(name = "BUPA_DEFVA")
    private String defaultValue;

}
