package com.rera.mss.model

import com.rera.mss.config.MEDIUM_STRING_FIELD_LENGTH
import org.hibernate.annotations.JoinColumnOrFormula
import org.hibernate.annotations.JoinColumnsOrFormulas
import org.hibernate.annotations.JoinFormula
import javax.persistence.*

@Entity
@Table(name = "Sys_Transition")
data class SysTransition(
        @Id
        @GeneratedValue(strategy = GenerationType.IDENTITY)
        var id: Long,

        @ManyToOne
        @JoinColumn(name = "role_id")
        var role: Role,

        @Column(name = "transition_name", length = MEDIUM_STRING_FIELD_LENGTH)
        var transitionName: String,


        @ManyToOne
        @JoinColumns(
                JoinColumn(name = "state_from", referencedColumnName = "state"),
                JoinColumn(name = "entity_name", referencedColumnName = "entity_name")
        )
        var stateFrom: SysState,

        @ManyToOne
        @JoinColumns(
                JoinColumn(name = "state_to", referencedColumnName = "state", insertable = false, updatable = false),
                JoinColumn(name = "entity_name", referencedColumnName = "entity_name", insertable = false, updatable = false)
        )
        var stateTo: SysState
)