OneToOne not work
sinadalvand opened this issue · 0 comments
sinadalvand commented
here I'm using SQLite and I'm trying to make a one-to-one association
Box class:
@Entity
data class Box(
@Id @GeneratedValue
val id: Long? = null,
@OneToOne
@JoinColumn(name = "item_id")
val item: Item
)
Item class:
@Entity
data class Item(
@Id @GeneratedValue
val id: Long? = null,
val size: Int,
@OneToOne(mappedBy = "item")
val box: Box? = null,
)
but when got null for item in below code :
transaction {
val item = ItemTable.insert(Item(size = 5))
val box = BoxTable.insert(Box(item = item))
val result = BoxTable.selectAll().first().toBox()
println(result) // problem ==> result.item = null
}
I tried different ways for the one-to-one association but nothing worked and I realized in generated code when it try to get Item for box it checks the existence of "ItemTable.id" instead of "BoxTable.item_id"
anyway, is this my implementation problem or library problem ?