I try to get hold of the id of an entity through a
manytoone mapping, but unsuccessful so far.
This is a very stripped down version,
and I hope my question still make sense.
=== ENTITIES =====
object A_Entity extends Entity[IntId, A] {
val id = key("id") sequence seq("A_SEQ") autogenerated (_.id)
val name = column("name") to (_.name)
def constructor(implicit m:ValuesMap) =
new A(name) with IntId with Persisted {
val id: Int = A_Entity.id
}
}
-----
object B_Entity extends Entity[IntId, B] {
val id = key("id") sequence seq("B_SEQ") autogenerated (_.id)
val A_item = manytoone(A_Entity) foreignkey("A_item_id") to (_.A_item)
def constructor(implicit m:ValuesMap) =
new B(A_item) with Persisted with IntId {
val id: Int = B_Entity.id
}
}
=== MODELS =====
case class A (
val name: String,
)
object A {
def empty = new A("")
}
-----
case class B(
val title: String,
val A_item:A,
)
object B {
def empty = new B(new A("")
}
=== DAOS ===
abstract class A_Dao extends TransactionalIntIdCRUD[A] with IntIdAll[A] {
entity = A_Entity
}
-----
abstract class B_Dao extends TransactionalIntIdCRUD[B] with IntIdAll[B] {
val entity = B_Entity
}
=== BUSINESS LOGIC ===
val B_all = B_Dao.all
b <- B_all
if (true)
b.A_item.id // DOES NOT EXIST
I can access the A_item.name but not the A_item.id
How can I get hold of A_item's id ?