> I'm having trouble understanding why that key mapping change wouldn't be
applied automatically when you change the column name, as I can't readily
imagine a scenario where you'd want different behavior.


I initially assumed like that: it's automatically done. But now the fact
says the other way around: it should be manually done. Well, it seems that's
just a lesson-of-the-day for me: not all things automatically done... :D




-- 
Regards,

Maximilian Haru Raditya






On Wed, Jul 13, 2011 at 11:36 PM, asher newcomer <[email protected]> wrote:

> Ah, okay, I see what you're saying.  And you're correct, I hadn't noticed
> that in my domain the properties that were not bi-directional worked
> properly.  Thank you very much for the help - that's what I get for coding
> tired.
>
> I'll still admit that I don't find this behavior intuitive.  I'm having
> trouble understanding why that key mapping change wouldn't be applied
> automatically when you change the column name, as I can't readily imagine a
> scenario where you'd want different behavior.  Also, if you have multiple
> collection types in your domain, you need to apply BeforeMapBag,
> BeforeMapSet, ..., all to change a reference which I'd think would be well
> known.  I'm sure I'm missing something, or perhaps it's a technical issue
> within NH that I'm not appreciating.
>
> In any case, thanks for the look.
>
> Regards
>
>
> On Wed, Jul 13, 2011 at 11:35 AM, José F. Romaniello <
> [email protected]> wrote:
>
>> Yes, I thought it was that.. thats the reason in Fabio's post he does:
>> mapper.BeforeMapManyToOne += (insp, prop, map) =>
>> map.Column(prop.LocalMember.GetPropertyOrFieldType().Name + "Id");
>>
>> But also he does:
>>
>> mapper.BeforeMapBag += (insp, prop, map) => map.Key(km =>
>> km.Column(prop.GetContainerEntity(insp).Name + "Id"));
>>
>>
>>
>>
>> 2011/7/13 Maximilian Raditya <[email protected]>
>>
>>> Oops, sorry. I didn't carefully notice that my domain model actually
>>> contains bidirectional mappings, that's why it failed. With unidirectional
>>> mapping (just many-to-one, without one-to-many in the form of bag/set/etc.),
>>> it's doing just fine.
>>>
>>> So, the other generated column (without Id) actually comes from the
>>> unchanged one-to-many key column name.
>>>
>>>
>>>
>>>
>>> --
>>> Regards,
>>>
>>> Maximilian Haru Raditya
>>>
>>>
>>>
>>>
>>> On Wed, Jul 13, 2011 at 2:17 PM, Maximilian Raditya <[email protected]>wrote:
>>>
>>>> I just noticed this. I've just tried it my domain model and it seems
>>>> like a bug. It ends up creating two columns for the same association, one
>>>> without Id and one with Id. I think Before* events should override existing
>>>> column definition, not add a new one.
>>>>
>>>> I think you can report this in JIRA.
>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> Regards,
>>>>
>>>> Maximilian Haru Raditya
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> On Wed, Jul 13, 2011 at 11:12 AM, asher newcomer <[email protected]>wrote:
>>>>
>>>>> Thanks José, and yes that post from Fabio is where I've drawn my
>>>>> inspiration here.  My code is almost identical to the following line from
>>>>> his:
>>>>>
>>>>>  mapper.BeforeMapManyToOne += (insp, prop, map) =>
>>>>> map.Column(prop.LocalMember.GetPropertyOrFieldType().Name + "Id");
>>>>>
>>>>> My particular example is actually not a bidirectional relationship
>>>>> (though I do have some in my domain), but I don't see why that should
>>>>> matter.  My 'Currency' object in this case does not have an 'Orders'
>>>>> property. .I'd only want to override the column naming convention for one
>>>>> side of the relationship in any case.  With the other side of the
>>>>> relationship (Currency.Orders), I'd be happy keeping the default behavior.
>>>>>
>>>>>
>>>>> On Tue, Jul 12, 2011 at 11:47 PM, José F. Romaniello <
>>>>> [email protected]> wrote:
>>>>>
>>>>>> No problem Asher, now we are talking.
>>>>>> I think it is not a bug, but you might be mapping a bidirectional
>>>>>> relationship..
>>>>>>
>>>>>> Like Order.Currency and Currency.Orders .. or something alike. If that
>>>>>> is your case, you are overriding only one of the mappings the one for
>>>>>> ManyToOne.
>>>>>> Please, check what Fabio did in this post
>>>>>> http://fabiomaulo.blogspot.com/2011/04/nhibernate-32-mapping-by-code_13.html
>>>>>>
>>>>>> 2011/7/13 asher newcomer <[email protected]>
>>>>>>
>>>>>>>  Apologies for the offense.  The name is a reference to the Eddie
>>>>>>> Murphy movie Coming to America:
>>>>>>>
>>>>>>> http://www.youtube.com/watch?v=7ef0JqH67V8
>>>>>>>
>>>>>>> I'll go ahead and change it.  I had frankly forgotten it was set as
>>>>>>> such.
>>>>>>>
>>>>>>> On Tue, Jul 12, 2011 at 11:38 PM, José F. Romaniello <
>>>>>>> [email protected]> wrote:
>>>>>>>
>>>>>>>> The name that you have used to send this mail ( SexualChocolate ) is
>>>>>>>> inappropriate and *it is not even funny*.
>>>>>>>> I hope the guys in this forum answer you with the same level of
>>>>>>>> seriousness.
>>>>>>>>
>>>>>>>> 2011/7/12 SexualChocolate <[email protected]>
>>>>>>>>
>>>>>>>>> Trying out the new ConventionModelMapper (just awesome, btw), and
>>>>>>>>> can't get the following to work correctly:
>>>>>>>>>
>>>>>>>>> mapper.BeforeMapManyToOne += (insp, typ, map) =>
>>>>>>>>> map.Column(typ.LocalMember.GetPropertyOrFieldType().Name + "Id");
>>>>>>>>>
>>>>>>>>> Let's say for example that I have a 'Order' object which has a
>>>>>>>>> 'Currency' property in a many to one relationship.  I want the
>>>>>>>>> following schema:
>>>>>>>>>
>>>>>>>>> create table Order(
>>>>>>>>>       [other columns]
>>>>>>>>>       CurrencyId INT
>>>>>>>>>    )
>>>>>>>>>
>>>>>>>>> But when I apply the above code it's generating:
>>>>>>>>>
>>>>>>>>> create table Order(
>>>>>>>>>       [other columns]
>>>>>>>>>       CurrencyId INT
>>>>>>>>>       Currency INT
>>>>>>>>>    )
>>>>>>>>>
>>>>>>>>> Am I going about this incorrectly or is this a bug?
>>>>>>>>>
>>>>>>>>> Thank you in advance
>>>>>>>>>
>>>>>>>>> --
>>>>>>>>> You received this message because you are subscribed to the Google
>>>>>>>>> Groups "nhusers" group.
>>>>>>>>> To post to this group, send email to [email protected].
>>>>>>>>> To unsubscribe from this group, send email to
>>>>>>>>> [email protected].
>>>>>>>>> For more options, visit this group at
>>>>>>>>> http://groups.google.com/group/nhusers?hl=en.
>>>>>>>>>
>>>>>>>>>
>>>>>>>>  --
>>>>>>>> You received this message because you are subscribed to the Google
>>>>>>>> Groups "nhusers" group.
>>>>>>>> To post to this group, send email to [email protected].
>>>>>>>> To unsubscribe from this group, send email to
>>>>>>>> [email protected].
>>>>>>>> For more options, visit this group at
>>>>>>>> http://groups.google.com/group/nhusers?hl=en.
>>>>>>>>
>>>>>>>
>>>>>>>  --
>>>>>>> You received this message because you are subscribed to the Google
>>>>>>> Groups "nhusers" group.
>>>>>>> To post to this group, send email to [email protected].
>>>>>>> To unsubscribe from this group, send email to
>>>>>>> [email protected].
>>>>>>> For more options, visit this group at
>>>>>>> http://groups.google.com/group/nhusers?hl=en.
>>>>>>>
>>>>>>
>>>>>>  --
>>>>>> You received this message because you are subscribed to the Google
>>>>>> Groups "nhusers" group.
>>>>>> To post to this group, send email to [email protected].
>>>>>> To unsubscribe from this group, send email to
>>>>>> [email protected].
>>>>>> For more options, visit this group at
>>>>>> http://groups.google.com/group/nhusers?hl=en.
>>>>>>
>>>>>
>>>>>  --
>>>>> You received this message because you are subscribed to the Google
>>>>> Groups "nhusers" group.
>>>>> To post to this group, send email to [email protected].
>>>>> To unsubscribe from this group, send email to
>>>>> [email protected].
>>>>> For more options, visit this group at
>>>>> http://groups.google.com/group/nhusers?hl=en.
>>>>>
>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>>  --
>>> You received this message because you are subscribed to the Google Groups
>>> "nhusers" group.
>>> To post to this group, send email to [email protected].
>>> To unsubscribe from this group, send email to
>>> [email protected].
>>> For more options, visit this group at
>>> http://groups.google.com/group/nhusers?hl=en.
>>>
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "nhusers" group.
>> To post to this group, send email to [email protected].
>> To unsubscribe from this group, send email to
>> [email protected].
>> For more options, visit this group at
>> http://groups.google.com/group/nhusers?hl=en.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "nhusers" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/nhusers?hl=en.
>

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

Reply via email to