Chat 관련 엔티티 클래스 구현

1:1 채팅인데 인간 대 인간이 아닌 ai 대 인간의 채팅을 구현해야 함.

User

package swu.pbl.ppap.user

import jakarta.persistence.*
import org.hibernate.usertype.UserType
import swu.pbl.ppap.chat.Conversation

@Entity
class User(
    @Id @GeneratedValue(strategy = GenerationType.IDENTITY)
    var id: Long? = null,

    var username: String,
    var password: String,
    var email: String,
    var phone: String,
    var userType: UserType,
    
    @OneToMany(mappedBy = "user", cascade = [(CascadeType.REMOVE)])
    var chatMessage: MutableSet<ChatMessage> = mutableSetOf(),

    @OneToMany(mappedBy = "user", cascade = [(CascadeType.REMOVE)])
    var conversation: MutableList<Conversation> = mutableListOf()

) {
    constructor() : this(null, "", "", "", "", UserType.PERSONAL){}

    enum class UserType {
        PERSONAL, CORPORATE
    }
}

회원가입에 필요한 정보

채팅 관련 정보

ChatMessage

package swu.pbl.ppap.chat

import jakarta.persistence.*
import swu.pbl.ppap.user.User
import java.time.LocalDateTime

@Entity
class ChatMessage (

    @Column
    var content: String,

    @Column
    var date: LocalDateTime,

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "user_id")
    var user: User,

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "conversation_id")
    var conversation: Conversation,

    @Id @GeneratedValue(strategy = GenerationType.IDENTITY)
    var id: Long? = null,

    ) {

    protected constructor(): this("", LocalDateTime.now(), User(), Conversation()){

    }
}

문제상황