package dp.kotul.templategroupsbackend.model.entity

import java.time.Instant
import javax.persistence.CascadeType
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.OneToMany

@Entity
class TemplateGroup(
        @Id
        @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "templateGroupSeq")
        @Column(name = "templateGroupId")
        val templateGroupId: Int = 0,

        @OneToMany(mappedBy = "templateGroup", cascade = [CascadeType.ALL], fetch = FetchType.LAZY)
        val templates: MutableList<Template> = mutableListOf(),

        @OneToMany(mappedBy = "templateGroup", cascade = [CascadeType.ALL], fetch = FetchType.LAZY)
        val templateGroupVariables: MutableList<TemplateGroupVariable> = mutableListOf(),

        @Column(nullable = false)
        val name: String,

        @Column(nullable = false)
        val comId: Int,

        @Column(nullable = false)
        val usrId: Int,

        @Column(nullable = false)
        val created: Instant,

        @Column(nullable = false)
        val lastModified: Instant
)
