[squeak-dev] SandstoneDb question

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

[squeak-dev] SandstoneDb question

EstebanLM
Hi,
I'm using SandstoneDb for a project... and I have this (one-to-many) scenario:

a) Product as Parts
b) a Part can be owner by a Product, or can be orphan

so, I have two roots: Product and Part

well, by design, Sandstone does not allow me to make a recursive
commit, and I have to make that commit by hand, something like this:

self product partsDo: [ :each |
        each isNew ifTrue: [ each commit ].
self product commit.

but... I need this behaivor in many parts of my environment, so I
rewrited #commit, this way:

Product>>commit
        self partsDo: [ :each |
                each isNew ifTrue: [ each commit ].
        super commit.

My question is: is this design right? Is there another -cleaner- way to
do this?

Thanks in advance,
Esteban

pd: maybe #commitWithRelations is better than overwrite commit?



Reply | Threaded
Open this post in threaded view
|

RE: [squeak-dev] SandstoneDb question

Ramon Leon-5

> Hi,
> I'm using SandstoneDb for a project... and I have this
> (one-to-many) scenario:
>
> a) Product as Parts
> b) a Part can be owner by a Product, or can be orphan
>
> so, I have two roots: Product and Part
>
> well, by design, Sandstone does not allow me to make a recursive
> commit, and I have to make that commit by hand, something like this:
>
> self product partsDo: [ :each |
> each isNew ifTrue: [ each commit ].
> self product commit.
>
> but... I need this behaivor in many parts of my environment, so I
> rewrited #commit, this way:
>
> Product>>commit
> self partsDo: [ :each |
> each isNew ifTrue: [ each commit ].
> super commit.
>
> My question is: is this design right? Is there another
> -cleaner- way to
> do this?
>
> Thanks in advance,
> Esteban

I'd say that's not a good approach.  The problem is you're adding new Parts
to a Product, if Part can stand alone, then save them prior to creating the
relationship.  Relationships are between committed objects.  You're trying
to treat the Part as an aggreagte of Product when it clearly isn't if a Part
can exist without a Product.

Ramon Leon


Reply | Threaded
Open this post in threaded view
|

Re: [squeak-dev] SandstoneDb question

Rob Rothwell
Hey Ramon...

Just wondering, only slightly off topic, if you can save the class itself with SandstoneDb?  I am doing some dynamic compilation, and was wondering if I can use SandstoneDb to save changes to the class without saving the entire image, or if I should just save the image when I add new methods or update class side variables?

Just wondering if there is a more "compact" way of saving just one class instead of the entire image?

Rob



Reply | Threaded
Open this post in threaded view
|

RE: [squeak-dev] SandstoneDb question

Ramon Leon-5
> Hey Ramon...
>
> Just wondering, only slightly off topic, if you can save the
> class itself with SandstoneDb?  I am doing some dynamic
> compilation, and was wondering if I can use SandstoneDb to
> save changes to the class without saving the entire image, or
> if I should just save the image when I add new methods or
> update class side variables?
>
> Just wondering if there is a more "compact" way of saving
> just one class instead of the entire image?
>
> Rob

No, you'll need to save your image, SandstoneDb just saves simple objects.

Ramon Leon
http://onsmalltalk.com


Reply | Threaded
Open this post in threaded view
|

Re: [squeak-dev] SandstoneDb question

Rob Rothwell
Thanks...the more I thought about it, the more complicated I realized this questions was; if you could "selectively save" a class and sync it up with any stored simple objects, you really wouldn't need much else at all for a lot of applications!

Thanks again,

Rob

On Wed, Aug 27, 2008 at 3:37 AM, Ramon Leon <[hidden email]> wrote:
> Hey Ramon...
>
> Just wondering, only slightly off topic, if you can save the
> class itself with SandstoneDb?  I am doing some dynamic
> compilation, and was wondering if I can use SandstoneDb to
> save changes to the class without saving the entire image, or
> if I should just save the image when I add new methods or
> update class side variables?
>
> Just wondering if there is a more "compact" way of saving
> just one class instead of the entire image?
>
> Rob

No, you'll need to save your image, SandstoneDb just saves simple objects.

Ramon Leon
http://onsmalltalk.com