Access to cached object in mapper (.obj)

19 views
Skip to first unread message

Jean-Adrien

unread,
Nov 5, 2009, 9:44:01 AM11/5/09
to Lift
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

David Pollak

unread,
Nov 5, 2009, 4:48:42 PM11/5/09
to lif...@googlegroups.com
Makes sense.  Please open a ticket: http://github.com/dpp/liftweb/issues
--
Lift, the simply functional web framework http://liftweb.net
Beginning Scala http://www.apress.com/book/view/1430219890
Follow me: http://twitter.com/dpp
Surf the harmonics

Naftoli Gugenheim

unread,
Nov 5, 2009, 5:26:20 PM11/5/09
to lif...@googlegroups.com
See also LongMappedMapper.

-------------------------------------

Jean-Adrien

unread,
Nov 6, 2009, 6:05:11 AM11/6/09
to Lift
Thanks a lot.

I opened the ticket: http://github.com/dpp/liftweb/issues/#issue/165
And I fixed my problem using LongMappedMapper.reload method.

On Nov 5, 11:26 pm, Naftoli Gugenheim <naftoli...@gmail.com> wrote:
> See also LongMappedMapper.
>
> -------------------------------------
>
> Beginning Scalahttp://www.apress.com/book/view/1430219890
Reply all
Reply to author
Forward
0 new messages