java - Play framework + ebean: Nested models are being saved as null -
i think simple problem: have 2 models, example;
@entity case class user(name: string, email: string) extends model { @id var id: int = 0 }
and then;
@entity case class task( subject: string, body: string, @manytoone user: user) extends model { @id var id: int = 0 }
what see when fetch tasks database (find().all()
), see user = null
tasks, while debugging, if set breakpoint @ newtask.save()
, see user field of instance correctly set.
what's wrong this?
thanks @salem, basically, link pointed out him suffices know going on – , can bit confusing.
what did define getter/setter references; in task
do;
@entity case class task (subject: string, body: string) { val userid: int = 0 // setter def user_= (user: user) = userid = user.id // getter def user:user = { user.find().byid(userid) // ensure find() defined in companion object } }
Comments
Post a Comment