package dp.kotul.templategroupsbackend.model.entity

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

@Entity
class TemplateGroupVariable(
        @Id
        @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "templateGroupVariableSeq")
        @Column(name = "templateGroupVariableId")
        val templateGroupVariableId: Int = 0,

        @JsonIgnore
        @ManyToOne(fetch = FetchType.LAZY)
        @JoinColumn(name = "templateGroupId")
        val templateGroup: TemplateGroup,

        val name: String?,

        val sortOrder: Int?,

        val defaultValue: String?,

        @Column(nullable = false)
        var mandatory: Boolean,

        @OneToOne(fetch = FetchType.LAZY)
        @JoinColumn(name = "templateVariableId")
        var templateVariable: TemplateVariable
)
