package dp.kotul.templategroupsbackend.model.entity

import com.fasterxml.jackson.annotation.JsonIgnore
import javax.persistence.Column
import javax.persistence.Entity
import javax.persistence.EnumType
import javax.persistence.Enumerated
import javax.persistence.FetchType
import javax.persistence.GeneratedValue
import javax.persistence.GenerationType
import javax.persistence.Id
import javax.persistence.OneToOne

@Entity
class VariableSource(
        @Id
        @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "variableSourceSeq")
        @Column(name = "variableSourceId")
        val variableSourceId: Int = 0,

        @JsonIgnore
        @OneToOne(mappedBy = "variableSource", fetch = FetchType.LAZY)
        val templateVariable: TemplateVariable?,

        val sourceId: String,

        @Column(nullable = false)
        @Enumerated(EnumType.STRING)
        val sourceType: VariableSourceType,

        val sourceFieldId: String?
)
