Yeah, that's the question :)

On Sat, Sep 20, 2008 at 4:47 PM, Ken Egozi <[EMAIL PROTECTED]> wrote:

> NH is actually two things.
> 1. an OR/M
> 2. a very smart DAL
>
> you can have entity model that reflects the DB's E/R in a 1:1 manner,
> without relations and collections, just primitive properties, and still
> enjoy the merits of NH (PI, Caches, efficient connection management, smart
> query capabilities).
>
> but what's the fun in that?
>
>
> On Sat, Sep 20, 2008 at 4:34 PM, Gustavo Ringel <[EMAIL PROTECTED]>wrote:
>
>> You may work without collections.
>>
>> If you have Order and OrderLine...you can query OrderLines doing something
>> like
>> "from OrderLine orderLine where orderLine.Order = :order"
>>
>> and you have the collection your self...
>>
>> You lose the option of encapsulating every call to order lines using the
>> repository for orders something you rarely want to lose.
>> You are giving a lot of info to the user now...using the option os mapping
>> the collection you can tell him how many order lines he has even without
>> knowledge of the order lines structure (you can map it with access = field
>> and hide it)
>>
>> for sure you have now to decide how to fetch the order lines in code while
>> putting order lines inside the order will give you the option to change the
>> fetching in mapping and using HQL or criteria...
>>
>> In resume you can work without mapping the collections...mapping big
>> collections is not a good practice so lot of times we are not mapping
>> collections where it is possible...but i don't think you have to set an
>> strategy working with or without them...you should use it or not depending
>> on your needs
>>
>> A rule of thumb one Fabio gave me: if you cannot map it with lazy=false
>> then it is not a good candidate to be inside the class...
>>
>> Gustavo.
>>
>>
>> On Sat, Sep 20, 2008 at 2:40 PM, N. D. <[EMAIL PROTECTED]> wrote:
>>
>>> Thanks Gustavo, you are right that i'm referring only to the mapping
>>> collections aspects of NH, i'm pretty much satisfied with everything else.
>>> when i think about it a bit more, the essence of the question is - if i
>>> don't use collection mapping at all and just work manually setting Ids - can
>>> you list the "good things" i lose?
>>>
>>>
>>>
>>>
>>> On Sat, Sep 20, 2008 at 3:35 PM, Gustavo Ringel <
>>> [EMAIL PROTECTED]> wrote:
>>>
>>>> Hi
>>>>
>>>> Regarding
>>>>
>>>> 1) NH is a PI framework, it will achieve it goals letting you to do same
>>>> things as you will do in the language without persistence.
>>>>
>>>> There is no magic in C# or Java that will give you a way to set only one
>>>> side of the collection and the other one will magically appear.
>>>>
>>>> 2) I don't see what the worry about with the cascade action is you must
>>>> write it in the mapping if you need it and you may not write it if you
>>>> don't...the same applies for opening a FK in a DB
>>>>
>>>> 3) The problem is not extra SQL the problem is which side is in charge
>>>> of the persistence.
>>>>
>>>> 4) You are using an advanced ORM because you want things like lazy
>>>> loading, you don't need to worry about them you can set default = false and
>>>> live in the old days without lazy loading...you use it because you know you
>>>> need it, it's not NH which will force you to use it and it won't decide to
>>>> you what's lazy or what not like SQL does not decide if you bring a joing
>>>> between two databases with a join or a select and a after that running with
>>>> a CURSOR...
>>>>
>>>> 5) many-to-many relations sometimes are really cruel...i try to avoid
>>>> them if i can.
>>>>
>>>>
>>>> Regarding the conclusion, you talked about thinks you consider
>>>> problematic mapping collections and then ask if NH only advantage is only 
>>>> on
>>>> querying, i don't think mapping a collection is even 0.01% of what the
>>>> framework brings...
>>>>
>>>> Gustavo.
>>>>
>>>>
>>>> On Sat, Sep 20, 2008 at 2:08 PM, ndotan <[EMAIL PROTECTED]> wrote:
>>>>
>>>>>
>>>>> Hey all,
>>>>> I have a theoretical question.i fail to see how nhibernate makes life
>>>>> easy for me by mapping relations.
>>>>>
>>>>> Every way i look at it, it seems that it poses more work to the
>>>>> programmer.
>>>>> for example taking directly from the documentation:
>>>>>
>>>>>
>>>>> http://www.hibernate.org/hib_docs/nhibernate/html/example-parentchild.html
>>>>>
>>>>> Parent p = (Parent) session.Load(typeof(Parent), pid);
>>>>> Child c = new Child();
>>>>> c.Parent = p;
>>>>> p.Children.Add(c);
>>>>> session.Save(c);
>>>>>
>>>>> 1. I need to maintain both edges of the link myself,
>>>>> 2. i need to worry about cascade action
>>>>> 3. i need to worry about the extra sql that is generated if i do not
>>>>> use inverse=true
>>>>> 4. i need to worry about when to use lazy loading.
>>>>> 5. in many to many relations, i need to worry twice as much.
>>>>>
>>>>> so is the only advantage in the querying? and if so, i imagine that
>>>>> most of the queries would be done in HQL and i could just do a join
>>>>> for the relations by hand.
>>>>>
>>>>>
>>>>> i feel im missing a point.
>>>>>
>>>>> thanks.
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>>
>>
>>
>>
>
>
>
> --
> Ken Egozi.
> http://www.kenegozi.com/blog
> http://www.musicglue.com
> http://www.castleproject.org
> http://www.gotfriends.co.il
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to nhusers@googlegroups.com
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