EmbeddedValueOneToOneMapping .. but in many tables

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

EmbeddedValueOneToOneMapping .. but in many tables

jtuchel
Hi,

I need to use some kind of EmbeddedValueOneToOneMapping to map objects that are embedded in other objects. But this object occurs in many (completely unrelated classes).

To be more concrete: I have many classes that have a date range (startDate, endDate) and would like to map the two attributes startDate and endDate to an instance of such a DateRange. EmbeddedValueOneToOneMapping requires the use of a descriptorForDateRange: method, which references a concrete table. So I cannot use EmbeddedValueOneToOneMapping, because DateRanges occur in many tables.

Example:

Class LifeTime is mapped to table LIFETIME with (among others) startDate and endDate.
Class Vacation is mapped to table Vacation with (among others)
startDate and endDate.
Class Education
is mapped to table Education with ... you already know.

These classes are not in a common inheritance hierarchy, but they all should use instances of DateRange for startDate and endDate. Interestingly, the database tables all have the exact same column names, so this sounds really easy, but I cannot figure it out on my own...

Any hint is welcome

Joachim

--
You received this message because you are subscribed to the Google Groups "glorp-group" group.
To view this discussion on the web visit https://groups.google.com/d/msg/glorp-group/-/nlTxiyB8GTwJ.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
For more options, visit this group at http://groups.google.com/group/glorp-group?hl=en.
Reply | Threaded
Open this post in threaded view
|

Re: EmbeddedValueOneToOneMapping .. but in many tables

Alan Knight-2
Embedded values support that, you just need to provide aliases for the fields. Look in the tests for things using currency objects, in e embedded mapping class for aliases, or for uses of imaginary table classes.

On Tuesday, October 9, 2012, jtuchel wrote:
Hi,

I need to use some kind of EmbeddedValueOneToOneMapping to map objects that are embedded in other objects. But this object occurs in many (completely unrelated classes).

To be more concrete: I have many classes that have a date range (startDate, endDate) and would like to map the two attributes startDate and endDate to an instance of such a DateRange. EmbeddedValueOneToOneMapping requires the use of a descriptorForDateRange: method, which references a concrete table. So I cannot use EmbeddedValueOneToOneMapping, because DateRanges occur in many tables.

Example:

Class LifeTime is mapped to table LIFETIME with (among others) startDate and endDate.
Class Vacation is mapped to table Vacation with (among others)
startDate and endDate.
Class Education
is mapped to table Education with ... you already know.

These classes are not in a common inheritance hierarchy, but they all should use instances of DateRange for startDate and endDate. Interestingly, the database tables all have the exact same column names, so this sounds really easy, but I cannot figure it out on my own...

Any hint is welcome

Joachim

--
You received this message because you are subscribed to the Google Groups "glorp-group" group.
To view this discussion on the web visit https://groups.google.com/d/msg/glorp-group/-/nlTxiyB8GTwJ.
To post to this group, send email to <a href="javascript:_e({}, &#39;cvml&#39;, &#39;glorp-group@googlegroups.com&#39;);" target="_blank">glorp-group@....
To unsubscribe from this group, send email to <a href="javascript:_e({}, &#39;cvml&#39;, &#39;glorp-group%2Bunsubscribe@googlegroups.com&#39;);" target="_blank">glorp-group+unsubscribe@....
For more options, visit this group at http://groups.google.com/group/glorp-group?hl=en.

--
You received this message because you are subscribed to the Google Groups "glorp-group" group.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
For more options, visit this group at http://groups.google.com/group/glorp-group?hl=en.
Reply | Threaded
Open this post in threaded view
|

Re: EmbeddedValueOneToOneMapping .. but in many tables

jtuchel
Alan,

I think I found what you mean:

    (aDescriptor newMapping: EmbeddedValueOneToOneMapping)
                attributeName: #amount;
                fieldTranslation: ((Join new)
                            addSource: (table fieldNamed: 'AMT_AMT')
                                target: ((self tableNamed: 'MONEY_IMAGINARY_TABLE') fieldNamed: 'AMOUNT');
                            addSource: (table fieldNamed: 'AMT_CURR')
                                target: ((self tableNamed: 'MONEY_IMAGINARY_TABLE') fieldNamed: 'CURRENCY');
                            yourself).


and

tableForMONEY_IMAGINARY_TABLE: aTable

    aTable createFieldNamed: 'CURRENCY' type: (platform varChar: 5).
    aTable createFieldNamed: 'AMOUNT' type: platform int4


But I am not sure if I understand what you mean by "aliases for the fields". what's aliased about the fields in this example?

Joachim



Am Dienstag, 9. Oktober 2012 18:00:04 UTC+2 schrieb Alan Knight:
Embedded values support that, you just need to provide aliases for the fields. Look in the tests for things using currency objects, in e embedded mapping class for aliases, or for uses of imaginary table classes.

On Tuesday, October 9, 2012, jtuchel wrote:
Hi,

I need to use some kind of EmbeddedValueOneToOneMapping to map objects that are embedded in other objects. But this object occurs in many (completely unrelated classes).

To be more concrete: I have many classes that have a date range (startDate, endDate) and would like to map the two attributes startDate and endDate to an instance of such a DateRange. EmbeddedValueOneToOneMapping requires the use of a descriptorForDateRange: method, which references a concrete table. So I cannot use EmbeddedValueOneToOneMapping, because DateRanges occur in many tables.

Example:

Class LifeTime is mapped to table LIFETIME with (among others) startDate and endDate.
Class Vacation is mapped to table Vacation with (among others)
startDate and endDate.
Class Education
is mapped to table Education with ... you already know.

These classes are not in a common inheritance hierarchy, but they all should use instances of DateRange for startDate and endDate. Interestingly, the database tables all have the exact same column names, so this sounds really easy, but I cannot figure it out on my own...

Any hint is welcome

Joachim


--
You received this message because you are subscribed to the Google Groups "glorp-group" group.
To view this discussion on the web visit https://groups.google.com/d/msg/glorp-group/-/4iY0mCIxTaMJ.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
For more options, visit this group at http://groups.google.com/group/glorp-group?hl=en.
Reply | Threaded
Open this post in threaded view
|

Re: EmbeddedValueOneToOneMapping .. but in many tables

Alan Knight-2
This is abusing a Join object to describe the aliasing rather than
describing a real join. So the descriptor for the currency object is
written in terms of mapping to MONEY_IMAGINARY_TABLE. That doesn't
actually exist, so in use, you have to tell it what to use instead. So
fieldTranslation does that. This is saying that if you see the field
'AMOUNT' in the table MONEY_IMAGINARY_TABLE, instead use the field
named 'AMT_AMT' in the table that's in the variable 'table'. But that
only applies to this particular mapping. In a different mapping that
uses the currency object it would use different fields.

In this example, I believe that there are two different currency
instances that are embedded into the same table.

On Tue, Oct 9, 2012 at 1:59 PM, jtuchel <[hidden email]> wrote:

> Alan,
>
> I think I found what you mean:
>
>     (aDescriptor newMapping: EmbeddedValueOneToOneMapping)
>                 attributeName: #amount;
>                 fieldTranslation: ((Join new)
>                             addSource: (table fieldNamed: 'AMT_AMT')
>                                 target: ((self tableNamed:
> 'MONEY_IMAGINARY_TABLE') fieldNamed: 'AMOUNT');
>                             addSource: (table fieldNamed: 'AMT_CURR')
>                                 target: ((self tableNamed:
> 'MONEY_IMAGINARY_TABLE') fieldNamed: 'CURRENCY');
>                             yourself).
>
> and
>
> tableForMONEY_IMAGINARY_TABLE: aTable
>
>     aTable createFieldNamed: 'CURRENCY' type: (platform varChar: 5).
>     aTable createFieldNamed: 'AMOUNT' type: platform int4
>
>
> But I am not sure if I understand what you mean by "aliases for the fields".
> what's aliased about the fields in this example?
>
> Joachim
>
>
>
> Am Dienstag, 9. Oktober 2012 18:00:04 UTC+2 schrieb Alan Knight:
>>
>> Embedded values support that, you just need to provide aliases for the
>> fields. Look in the tests for things using currency objects, in e embedded
>> mapping class for aliases, or for uses of imaginary table classes.
>>
>> On Tuesday, October 9, 2012, jtuchel wrote:
>>>
>>> Hi,
>>>
>>> I need to use some kind of EmbeddedValueOneToOneMapping to map objects
>>> that are embedded in other objects. But this object occurs in many
>>> (completely unrelated classes).
>>>
>>> To be more concrete: I have many classes that have a date range
>>> (startDate, endDate) and would like to map the two attributes startDate and
>>> endDate to an instance of such a DateRange. EmbeddedValueOneToOneMapping
>>> requires the use of a descriptorForDateRange: method, which references a
>>> concrete table. So I cannot use EmbeddedValueOneToOneMapping, because
>>> DateRanges occur in many tables.
>>>
>>> Example:
>>>
>>> Class LifeTime is mapped to table LIFETIME with (among others) startDate
>>> and endDate.
>>> Class Vacation is mapped to table Vacation with (among others) startDate
>>> and endDate.
>>> Class Education is mapped to table Education with ... you already know.
>>>
>>> These classes are not in a common inheritance hierarchy, but they all
>>> should use instances of DateRange for startDate and endDate. Interestingly,
>>> the database tables all have the exact same column names, so this sounds
>>> really easy, but I cannot figure it out on my own...
>>>
>>> Any hint is welcome
>>>
>>> Joachim
>>>
>>>
> --
> You received this message because you are subscribed to the Google Groups
> "glorp-group" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/glorp-group/-/4iY0mCIxTaMJ.
>
> To post to this group, send email to [hidden email].
> To unsubscribe from this group, send email to
> [hidden email].
> For more options, visit this group at
> http://groups.google.com/group/glorp-group?hl=en.

--
You received this message because you are subscribed to the Google Groups "glorp-group" group.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
For more options, visit this group at http://groups.google.com/group/glorp-group?hl=en.

Reply | Threaded
Open this post in threaded view
|

Re: EmbeddedValueOneToOneMapping .. but in many tables

jtuchel
Hi Alan,

thanks for your explanation.
Using a JOIN in this situation sounds a bit strange in this scenario, but it really works.

Once again your input is very valuable!

Joachim


Am Dienstag, 9. Oktober 2012 23:48:55 UTC+2 schrieb Alan Knight:
This is abusing a Join object to describe the aliasing rather than
describing a real join. So the descriptor for the currency object is
written in terms of mapping to MONEY_IMAGINARY_TABLE. That doesn't
actually exist, so in use, you have to tell it what to use instead. So
fieldTranslation does that. This is saying that if you see the field
'AMOUNT' in the table MONEY_IMAGINARY_TABLE, instead use the field
named 'AMT_AMT' in the table that's in the variable 'table'. But that
only applies to this particular mapping. In a different mapping that
uses the currency object it would use different fields.

In this example, I believe that there are two different currency
instances that are embedded into the same table.

On Tue, Oct 9, 2012 at 1:59 PM, jtuchel <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="5Prsvgn5qQgJ">jtu...@...> wrote:

> Alan,
>
> I think I found what you mean:
>
>     (aDescriptor newMapping: EmbeddedValueOneToOneMapping)
>                 attributeName: #amount;
>                 fieldTranslation: ((Join new)
>                             addSource: (table fieldNamed: 'AMT_AMT')
>                                 target: ((self tableNamed:
> 'MONEY_IMAGINARY_TABLE') fieldNamed: 'AMOUNT');
>                             addSource: (table fieldNamed: 'AMT_CURR')
>                                 target: ((self tableNamed:
> 'MONEY_IMAGINARY_TABLE') fieldNamed: 'CURRENCY');
>                             yourself).
>
> and
>
> tableForMONEY_IMAGINARY_TABLE: aTable
>
>     aTable createFieldNamed: 'CURRENCY' type: (platform varChar: 5).
>     aTable createFieldNamed: 'AMOUNT' type: platform int4
>
>
> But I am not sure if I understand what you mean by "aliases for the fields".
> what's aliased about the fields in this example?
>
> Joachim
>
>
>
> Am Dienstag, 9. Oktober 2012 18:00:04 UTC+2 schrieb Alan Knight:
>>
>> Embedded values support that, you just need to provide aliases for the
>> fields. Look in the tests for things using currency objects, in e embedded
>> mapping class for aliases, or for uses of imaginary table classes.
>>
>> On Tuesday, October 9, 2012, jtuchel wrote:
>>>
>>> Hi,
>>>
>>> I need to use some kind of EmbeddedValueOneToOneMapping to map objects
>>> that are embedded in other objects. But this object occurs in many
>>> (completely unrelated classes).
>>>
>>> To be more concrete: I have many classes that have a date range
>>> (startDate, endDate) and would like to map the two attributes startDate and
>>> endDate to an instance of such a DateRange. EmbeddedValueOneToOneMapping
>>> requires the use of a descriptorForDateRange: method, which references a
>>> concrete table. So I cannot use EmbeddedValueOneToOneMapping, because
>>> DateRanges occur in many tables.
>>>
>>> Example:
>>>
>>> Class LifeTime is mapped to table LIFETIME with (among others) startDate
>>> and endDate.
>>> Class Vacation is mapped to table Vacation with (among others) startDate
>>> and endDate.
>>> Class Education is mapped to table Education with ... you already know.
>>>
>>> These classes are not in a common inheritance hierarchy, but they all
>>> should use instances of DateRange for startDate and endDate. Interestingly,
>>> the database tables all have the exact same column names, so this sounds
>>> really easy, but I cannot figure it out on my own...
>>>
>>> Any hint is welcome
>>>
>>> Joachim
>>>
>>>
> --
> You received this message because you are subscribed to the Google Groups
> "glorp-group" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/glorp-group/-/4iY0mCIxTaMJ.
>
> To post to this group, send email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="5Prsvgn5qQgJ">glorp...@....
> To unsubscribe from this group, send email to
> <a href="javascript:" target="_blank" gdf-obfuscated-mailto="5Prsvgn5qQgJ">glorp-group...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/glorp-group?hl=en.

--
You received this message because you are subscribed to the Google Groups "glorp-group" group.
To view this discussion on the web visit https://groups.google.com/d/msg/glorp-group/-/0c6JjabGLmgJ.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
For more options, visit this group at http://groups.google.com/group/glorp-group?hl=en.