Answer the question
In order to leave comments, you need to log in
How to work with links in Ebean ORM?
Hello, I just can't figure out how to work with one-to-many relationships in Ebean ORM. Suppose there are such entities
@Entity
open class Member() {
@ManyToOne(optional = false)
open var group: Group? = null
}
@Entity
open class Group() {
@OneToMany(mappedBy = "group", fetch = FetchType.EAGER, cascade = arrayOf(CascadeType.ALL))
open var members: MutableList<Member> = ArrayList()
}
//группа в переменной gr
val memb: Member = Member("testName")
memb.group = gr
gr.members.add(memb)
ebeanServer.save(gr)
ebeanServer.save(gr)
com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry '494' for key 'PRIMARY'
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question