package com.server.alb.models import jakarta.persistence.* @Entity @Table(name = "users") class User() { @Id @Column(name = "user_id") @GeneratedValue(strategy = GenerationType.IDENTITY) var id: Long = 0 var username: String = "" var password: String = "" var isEnabled = false @ManyToMany(cascade = [CascadeType.ALL], fetch = FetchType.EAGER) @JoinTable( name = "users_roles", joinColumns = [JoinColumn(name = "user_id")], inverseJoinColumns = [JoinColumn(name = "role_id")] ) var roles: Set = HashSet() @OneToMany(mappedBy = "qcId", cascade = [CascadeType.ALL], orphanRemoval = true) var qcId: List = mutableListOf() @OneToMany(mappedBy = "proId", cascade = [CascadeType.ALL], orphanRemoval = true) var proId: List = mutableListOf() @Transient var roleName: Role? = null @PostLoad fun onLoad() { for (role in roles) { roleName = role } } }