Hello,
I have a question regarding the .obj field in MappedForeignKey trait;
If I load a persisted object, if see that I can modify the value of
one MappedForeignKey column, and the change is not reflected in .obj
method. Doesn't it make sense to have the updated value, since the .is
method returns the updated foreign key:
val testUser : User = User.find(By(User.id, 1)).open_!
val testAddress = testUser.homeAddress.obj;
Log.debug("Current FK id is "+
testUser.homeAddress.is) // returns 1
testAddress match {
case Full(addr) =>
val anotherAddr : Address = Address.find(By(Address.id,
2)).open_!
Log.debug("There was an address: "+addr+". Replace it with
addr id#2: "+anotherAddr);
testUser.homeAddress(anotherAddr).save
case _ =>
[...]
}
val retestAddress = testUser.homeAddress.obj
Log.debug("Now obj is "+retestAddress); // returns a Box with the
old address (former id)
Log.debug("And is is "+
testUser.homeAddress.is) // returns 2
By the way, what is the best method to reload the changes, if, i.e. I
have no reference on the query that produced the original (parent)
object (e.g. testUser), and therefore no way to reload it