The entity class associated to task table should look as follows:
@Entity
@Table(name="task",catalog="task_mgmt_system")
class Task {
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
@Column(name = "id")
private var id :Int?=null
@Column(name="title")
private var title : String? = null
@Column(name="detail")
private var detail : String? = null
@Column(name="assigned_to")
private var assignedTo : Int? = null
@Column(name="status")
private var status : String? = null
@OneToMany
@JoinColumn(name ="task_id")
private var comments : MutableSet<Comments>? = null
// .. Getters and Setters
}
The @OneToMany annotation is used to declare a one-to-many relationship with the comments table. The @JoinColumn annotation is used to declare the column reference in the comments table.