Send to Printer

st4u

ST 4U 169: Refreshing an Object with GLORP

December 12, 2011 9:20:15.805

Today's Smalltalk 4 Youlooks at refreshing objects that we have previously read using Glorp - this may be necessary if another process (or user) has updated the source database information since we last read it. The initial setup used is described here. If you have trouble viewing it here in the browser, you can also navigate directly to YouTube. To watch now, click on the image below:

Refreshing.

If you have trouble viewing that directly, you can click here to download the video directly. If you need the video in a Windows Media format, then download that here.

You can also watch it on YouTube:


Today we'll look at how to refresh objects that you have read out of the database. For simple client/server apps, this might never be needed, but in any app where multiple users could be reading and writing the same data, you'll likely end up using this. First, let's read an object into memory:


"read one"
emp := session readOneOf: Emp where: [:each | each firstName = 'Fred'].


Now, assume that some time has passed, or an event has been received indicating that the object in question has changed on the database side. To ensure that we have the most recent copy, we do this:


"time passes....
emp := session refresh: emp.

Need more help? There's a screencast for other topics like this which you may want to watch. Questions? Try the "Chat with James" Google gadget over in the sidebar.

Technorati Tags: , ,

Enclosures:
[st4u169-iPhone.m4v ( Size: 1875028 )]

posted by James Robertson

 Share Tweet This