database – Squeryl: Reference to parent object in OneToMany relation

بدون دیدگاه

For example, we have 2 classes: Parent and Child. And OneToMany relation between them. And both classes have fields like:

 lazy val childs = SomeSchema.childToParentRelation.leftStateful(this)

In PARENT class


lazy val parent = SomeSchema.childToParentRelation.right(this).single

In CHILD class

When i try to access from parent to child, i can use “parent.childs.toList” and get all child objects. Than, i use one of them and try to get parent. Okay, but it create NEW object of parent insted of just return exist parent object. It’s vary bad for performance. How to fix it?

لینک منبع

  • نویسنده
  • تعداد بازدید
0دیدگاه فرستاده شده است.
شما هم دیدگاه خود را بنویسید