[vwnc] Can Glorp make strange

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

[vwnc] Can Glorp make strange

vam
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: [vwnc] Can Glorp make strange

Alan Knight-2
What you want to do is define a mapping that doesn't actually get read or written to an instance variable, and so can only be used for queries. So just define a Basket->items mapping, and send it the message #beForPseudoVariable

At 05:05 PM 4/21/2009, VAM wrote:

Hi!

Can Glorp make next:
I have classes Basket and  BasketItem. BasketItem contains 'quantity' and
'price' as instance variables
And BasketItem contains basket instance variable as link to it's basket.
Basket _not_ contains collection of BasketItem.
I want implement mapping for Basket thus Glorp read instance of Basket from
DB, it read sum(item price * item quantity) and put sum into amount
variable.
May be I try to use AdHocMapping?



--
View this message in context: http://www.nabble.com/-vwnc--Can-Glorp-make-strange-tp23164976p23164976.html
Sent from the VisualWorks mailing list archive at Nabble.com.

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc

--
Alan Knight [|], Engineering Manager, Cincom Smalltalk

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
vam
Reply | Threaded
Open this post in threaded view
|

Re: [vwnc] Can Glorp make strange

vam
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: [vwnc] Can Glorp make strange

Alan Knight-2
Ah. Then what you want to do, I think, is create a relationship mapping to Basket (as a OneToOne), make it read-only and then do
    basketMapping query retrieve: [:each | (each quantity * each price) sum].
but I haven't tried this, it's just off the top of my head. I'll check it out tomorrow.

At 05:03 PM 4/22/2009, VAM wrote:

Hm-m, I think than I cannot right described my idea.

I want that when reading Basket object, read (only) sum(item price * item
quantity) into Basket instance variable.
Equal next smalltalk code:
basket := glorpSession readOneOf: Basket.
query := Query read: Item where: [:each | each basket = basket].
query retrieve: [:each | each quantity * each price].
basket amount: (glorpSession execute: query).

I don't want describe items as toManyMapping for Basket (basket can contents
thousands items), but I needed know total amount of all basket items.



Alan Knight-2 wrote:
>
> What you want to do is define a mapping that doesn't actually get read or
> written to an instance variable, and so can only be used for queries. So
> just define a Basket->items mapping, and send it the message
> #beForPseudoVariable
>
> At 05:05 PM 4/21/2009, VAM wrote:
>
>>Hi!
>>
>>Can Glorp make next:
>>I have classes Basket and  BasketItem. BasketItem contains 'quantity' and
>>'price' as instance variables
>>And BasketItem contains basket instance variable as link to it's basket.
>>Basket _not_ contains collection of BasketItem.
>>I want implement mapping for Basket thus Glorp read instance of Basket
from
>>DB, it read sum(item price * item quantity) and put sum into amount
>>variable.
>>May be I try to use AdHocMapping?
>>
>>
>>
>>--
>>View this message in context:
http://www.nabble.com/-vwnc--Can-Glorp-make-strange-tp23164976p23164976.html
>>Sent from the VisualWorks mailing list archive at Nabble.com.
>>
>>_______________________________________________
>>vwnc mailing list
>>[hidden email]
>> http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
>
> --
> Alan Knight [|], Engineering Manager, Cincom Smalltalk
> [hidden email]
> [hidden email]
> http://www.cincom.com/smalltalk
>
> _______________________________________________
> vwnc mailing list
> [hidden email]
> http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
>
>

--
View this message in context: http://www.nabble.com/-vwnc--Can-Glorp-make-strange-tp23164976p23175856.html
Sent from the VisualWorks mailing list archive at Nabble.com.

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc

--
Alan Knight [|], Engineering Manager, Cincom Smalltalk

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc