[Pharo-project] Fwd: [Pharocasts] New comment on SandstoneDb, simple ActiveRecord style persistence....
Someone knows ? Laurent ---------- Forwarded message ---------- From: Bernat Romagosa <noreply-comment@blogger.com> Date: Wed, May 4, 2011 at 1:37 PM Subject: [Pharocasts] New comment on SandstoneDb, simple ActiveRecord style persistence.... To: laurent.laffont@gmail.com Bernat Romagosa <http://www.blogger.com/profile/04492856362620588522> has left a new comment on your post "SandstoneDb, simple ActiveRecord style persistence...<http://www.pharocasts.com/2010/04/sandstonedb-simple-activerecord-style.html>": I was trying to migrate a simple image-based persistence app into Sandstone, so I just recompiled my biz objects to be subclasses of SDActiveRecord, but of course the objects I want to save are already created and "floating" in the image, so when I try to save them I get an error as many instvars haven't been initialized upon creating these objects (as they were already there). Is there a way to automatically do this? Thanks! Bernat. Posted by Bernat Romagosa to Pharocasts <http://www.pharocasts.com/> at May 4, 2011 4:37 AM
maybe the initialization can be done in the inspector by iterating over all instances that have some instances set to nil... (MyObject allInstances select: [:ea | ea createdOn isNil]) do: [:ea | ea initInstVarsFromSDFramework] where initInstVarsFromSDFramework would be somethin like super initialize + maybe some tweaks on createdOn... SDActiveRecord>> initialize super initialize. id := UUID new asString36. createdOn := updatedOn := DateAndTime now. version := 0. isNew := true hth, Cédrick
participants (2)
-
Cédrick Béler -
laurent laffont