Fwd: [Pharocasts] New comment on SandstoneDb, simple ActiveRecord style persistence....

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
14 messages Options
Reply | Threaded
Open this post in threaded view
|

Fwd: [Pharocasts] New comment on SandstoneDb, simple ActiveRecord style persistence....

laurent laffont

Someone knows ?

Laurent


---------- Forwarded message ----------
From: Bernat Romagosa <[hidden email]>
Date: Wed, May 4, 2011 at 1:37 PM
Subject: [Pharocasts] New comment on SandstoneDb, simple ActiveRecord style persistence....
To: [hidden email]


Bernat Romagosa has left a new comment on your post "SandstoneDb, simple ActiveRecord style persistence...":

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 at May 4, 2011 4:37 AM

Reply | Threaded
Open this post in threaded view
|

Re: [Pharocasts] New comment on SandstoneDb, simple ActiveRecord style persistence....

laurent laffont
On Wed, May 4, 2011 at 7:00 PM, Ramon Leon <[hidden email]> wrote:
My general approach would be this sequence of steps, let's assume his
class is called Person in collection var name people.

If Person has an initialize method, rename it to initializeOld.
Change superclass of Person to SDActiveRecord.
Person warmUp. to setup the store for this new class.
people do: [:e | e initialize ] to invoke active records initialize
setting up it's necessary inst vars and marking all people as new
rename Person>>initializeOld back to Person>>initialize.
people do: [:e | e save ]

Migration complete.



Thanks a lot Ramon, I add this to Pharocasts.

Laurent

 
--
Ramon Leon
http://onsmalltalk.com


On Wed, May 4, 2011 at 4:58 AM, laurent laffont
<[hidden email]> wrote:
>
> Someone knows ?
> Laurent
>
>
> ---------- Forwarded message ----------
> From: Bernat Romagosa <[hidden email]>
> Date: Wed, May 4, 2011 at 1:37 PM
> Subject: [Pharocasts] New comment on SandstoneDb, simple ActiveRecord style
> persistence....
> To: [hidden email]
>
>
> Bernat Romagosa has left a new comment on your post "SandstoneDb, simple
> ActiveRecord style persistence...":
>
> 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 at May 4, 2011 4:37 AM
>

Reply | Threaded
Open this post in threaded view
|

Re: [Pharocasts] New comment on SandstoneDb, simple ActiveRecord style persistence....

Stéphane Ducasse
something that would be good is to have SActiveRecord as a trait like in SqueakSave
this way no need to change the superclass definition of your domain to save your objects.

Stef
On May 4, 2011, at 9:01 PM, laurent laffont wrote:

> On Wed, May 4, 2011 at 7:00 PM, Ramon Leon <[hidden email]> wrote:
> My general approach would be this sequence of steps, let's assume his
> class is called Person in collection var name people.
>
> If Person has an initialize method, rename it to initializeOld.
> Change superclass of Person to SDActiveRecord.
> Person warmUp. to setup the store for this new class.
> people do: [:e | e initialize ] to invoke active records initialize
> setting up it's necessary inst vars and marking all people as new
> rename Person>>initializeOld back to Person>>initialize.
> people do: [:e | e save ]
>
> Migration complete.
>
>
>
> Thanks a lot Ramon, I add this to Pharocasts.
>
> Laurent
>
>  
> --
> Ramon Leon
> http://onsmalltalk.com
>
>
> On Wed, May 4, 2011 at 4:58 AM, laurent laffont
> <[hidden email]> wrote:
> >
> > Someone knows ?
> > Laurent
> >
> >
> > ---------- Forwarded message ----------
> > From: Bernat Romagosa <[hidden email]>
> > Date: Wed, May 4, 2011 at 1:37 PM
> > Subject: [Pharocasts] New comment on SandstoneDb, simple ActiveRecord style
> > persistence....
> > To: [hidden email]
> >
> >
> > Bernat Romagosa has left a new comment on your post "SandstoneDb, simple
> > ActiveRecord style persistence...":
> >
> > 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 at May 4, 2011 4:37 AM
> >
>


Reply | Threaded
Open this post in threaded view
|

Re: [Pharocasts] New comment on SandstoneDb, simple ActiveRecord style persistence....

Ramon Leon-5
On 05/04/2011 02:37 PM, Stéphane Ducasse wrote:
> something that would be good is to have SActiveRecord as a trait like in SqueakSave
> this way no need to change the superclass definition of your domain to save your objects.

As far as I'm aware, traits don't do instance variables, of which active
record has a few, as well as a class instance variable and a class
variable.  It also actually uses the class hierarchy throughout to allow
classes to do queries on all its instances and sub instances.
SDActiveRecord is a bundle of both behavior and state; not suitable for
a trait.

Beyond that, it's an opinionated library, your superclass should be
SDActiveRecord, because you shouldn't be trying to use an object that
has some other superclass as the aggregate root of a persistent bundle
of objects.  All of your business objects don't need to subclass
SDActiveRecord, just the aggregate roots.  Member biz objects can use
whatever superclass they like as long as it's serializable.

--
Ramon Leon
http://onsmalltalk.com

Reply | Threaded
Open this post in threaded view
|

Re: [Pharocasts] New comment on SandstoneDb, simple ActiveRecord style persistence....

Bernat Romagosa
Thanks a lot everyone, I'll start migrating it right way :)

Bernat Romagosa.
Reply | Threaded
Open this post in threaded view
|

Re: [Pharocasts] New comment on SandstoneDb, simple ActiveRecord style persistence....

Bernat Romagosa
I'm still having some trouble migrating the DB... I have an object that holds a Matrix, and whenever I attempt to save the object, SandstoneDB tries to remove elements from the matrix by using remove:, which it shouldNotImplement. Is there an easy workaround for this?

2011/5/5 Bernat Romagosa <[hidden email]>
Thanks a lot everyone, I'll start migrating it right way :)

Bernat Romagosa.

Reply | Threaded
Open this post in threaded view
|

Re: [Pharocasts] New comment on SandstoneDb, simple ActiveRecord style persistence....

Ramon Leon-5
On 05/06/2011 02:33 AM, Bernat Romagosa wrote:
> I'm still having some trouble migrating the DB... I have an object that
> holds a Matrix, and whenever I attempt to save the object, SandstoneDB
> tries to remove elements from the matrix by using remove:, which it
> shouldNotImplement. Is there an easy workaround for this?

Sounds like a bug, I'll look into it.

--
Ramon Leon
http://onsmalltalk.com

Reply | Threaded
Open this post in threaded view
|

Re: [Pharocasts] New comment on SandstoneDb, simple ActiveRecord style persistence....

Ramon Leon-5
In reply to this post by Bernat Romagosa
On 05/06/2011 02:33 AM, Bernat Romagosa wrote:
> I'm still having some trouble migrating the DB... I have an object that
> holds a Matrix, and whenever I attempt to save the object, SandstoneDB
> tries to remove elements from the matrix by using remove:, which it
> shouldNotImplement. Is there an easy workaround for this?

Pull down the latest code, it should work now.

--
Ramon Leon
http://onsmalltalk.com

Reply | Threaded
Open this post in threaded view
|

Re: [Pharocasts] New comment on SandstoneDb, simple ActiveRecord style persistence....

Bernat Romagosa
Thanks Ramon, it works now :)

2011/5/6 Ramon Leon <[hidden email]>
On 05/06/2011 02:33 AM, Bernat Romagosa wrote:
I'm still having some trouble migrating the DB... I have an object that
holds a Matrix, and whenever I attempt to save the object, SandstoneDB
tries to remove elements from the matrix by using remove:, which it
shouldNotImplement. Is there an easy workaround for this?

Pull down the latest code, it should work now.


--
Ramon Leon
http://onsmalltalk.com


Reply | Threaded
Open this post in threaded view
|

Re: [Pharocasts] New comment on SandstoneDb, simple ActiveRecord style persistence....

Bernat Romagosa
... but now I've really weird problems when saving a dictionary. I can only save 4 entries, no matter what I do. If I try to add a 5th item, one of the four previously saved ones will be replaced by it.

By the way, I ran the tests and got 6 failures and 4 errors, precisely at dictionaries, matrices and finding items, here's a shot: http://i.imgur.com/Q3sTg.png



2011/5/9 Bernat Romagosa <[hidden email]>
Thanks Ramon, it works now :)


2011/5/6 Ramon Leon <[hidden email]>
On 05/06/2011 02:33 AM, Bernat Romagosa wrote:
I'm still having some trouble migrating the DB... I have an object that
holds a Matrix, and whenever I attempt to save the object, SandstoneDB
tries to remove elements from the matrix by using remove:, which it
shouldNotImplement. Is there an easy workaround for this?

Pull down the latest code, it should work now.


--
Ramon Leon
http://onsmalltalk.com



Reply | Threaded
Open this post in threaded view
|

Re: [Pharocasts] New comment on SandstoneDb, simple ActiveRecord style persistence....

Ramon Leon-5
On 05/09/2011 03:06 AM, Bernat Romagosa wrote:
> ... but now I've really weird problems when saving a dictionary. I can
> only save 4 entries, no matter what I do. If I try to add a 5th item,
> one of the four previously saved ones will be replaced by it.

Any chance you can send me an image with this issue? Everything seems to
work fine here in Pharo 1.1, 1.2, and Squeak.  If you can't, then maybe
some more info on your exact configuration?

--
Ramon Leon
http://onsmalltalk.com

Reply | Threaded
Open this post in threaded view
|

Re: [Pharocasts] New comment on SandstoneDb, simple ActiveRecord style persistence....

Bernat Romagosa
Hi Ramon,

That's weird... here's my configuration: Pharo 1.2.1 using Croquet Closure Cog VM [CoInterpreter VMMaker-oscog.51] on Debian Lenny.

My image is quite massive right now, I'll try to get a smaller one with the same issue and send it to you later.

Thanks!

2011/5/9 Ramon Leon <[hidden email]>
On 05/09/2011 03:06 AM, Bernat Romagosa wrote:
... but now I've really weird problems when saving a dictionary. I can
only save 4 entries, no matter what I do. If I try to add a 5th item,
one of the four previously saved ones will be replaced by it.

Any chance you can send me an image with this issue? Everything seems to work fine here in Pharo 1.1, 1.2, and Squeak.  If you can't, then maybe some more info on your exact configuration?


--
Ramon Leon
http://onsmalltalk.com


Reply | Threaded
Open this post in threaded view
|

Re: [Pharocasts] New comment on SandstoneDb, simple ActiveRecord style persistence....

Bernat Romagosa
Here's the promised image, I left the test runner open: http://www.megaupload.com/?d=7VWBC7HU

Cheers,

Bernat.

2011/5/10 Bernat Romagosa <[hidden email]>
Hi Ramon,

That's weird... here's my configuration: Pharo 1.2.1 using Croquet Closure Cog VM [CoInterpreter VMMaker-oscog.51] on Debian Lenny.

My image is quite massive right now, I'll try to get a smaller one with the same issue and send it to you later.

Thanks!

2011/5/9 Ramon Leon <[hidden email]>
On 05/09/2011 03:06 AM, Bernat Romagosa wrote:
... but now I've really weird problems when saving a dictionary. I can
only save 4 entries, no matter what I do. If I try to add a 5th item,
one of the four previously saved ones will be replaced by it.

Any chance you can send me an image with this issue? Everything seems to work fine here in Pharo 1.1, 1.2, and Squeak.  If you can't, then maybe some more info on your exact configuration?


--
Ramon Leon
http://onsmalltalk.com



Reply | Threaded
Open this post in threaded view
|

Re: [Pharocasts] New comment on SandstoneDb, simple ActiveRecord style persistence....

Ramon Leon-5
On 05/10/2011 05:12 AM, Bernat Romagosa wrote:
> Here's the promised image, I left the test runner open:
> http://www.megaupload.com/?d=7VWBC7HU
>
> Cheers, Bernat.

Generally speaking, you should consider the image and changes file a
pair and always send them together zipped.  You might also sign up for a
free Dropbox account at http://db.tt/slWGE17, it makes sharing large
files trivial and free with direct links to them instead of forcing me
to watch ads while waiting for a countdown.

Here's a link to that image with the test running still up and all tests
passing...

http://dl.dropbox.com/u/7097835/SandstoneDBTestFails.image

I didn't do anything at all, I simply ran the tests and they all passed.
  You've got something weird going on with your system.  I'm also using
cog, here's my version info...

cog -version
3.9-7 #1 Fri Apr  1 12:48:48 PDT 2011 gcc 4.1.2
Croquet Closure Cog VM [CoInterpreter VMMaker-oscog.54]
Linux mcqfes 2.6.18-128.el5 #1 SMP Wed Jan 21 10:44:23 EST 2009 i686
i686 i386 GNU/Linux
plugin path: /usr/local/lib/squeak/3.9-7/ [default:
/usr/local/lib/squeak/3.9-7/]

So I'd suggest downloading a fresh one click image from the Pharo site,
loading SandstoneDb, and running the tests again.  If that fails,
perhaps there are some permissions issues with the folders, try renaming
the image and restarting it so a fresh set of folders are created and
see if that helps.  If you find more info or the issue I'm definitely
interested in what caused it since I can't recreate the issue even in
your image.

--
Ramon Leon
http://onsmalltalk.com