2009/3/18 Jiho Han <[email protected]>

>
> 1. Does NHibernate require an identity field/property on an object?


No. You can declare <id> only for persistence matters with have an id in
your entity implementation.


>
> 2. Most of the examples I found used public get/set for an identity -
> certainly this is for demonstration purpose, correct?  I read
> somewhere that NHibernate can use reflection to update a private field
> instead.


Yes.


> 3. Related to #2, when you create a new object and so it does not have
> an id yet, after you persist it, does NHibernate assign the id to the
> SAME object?


It depend. If you use Save and you have an POID property/field the answer is
yes.


> 4. If a client has a reference on an object dished out by NHibernate,
> but NHibernate "refreshes", then when the client tries to "update",
> will NHibernate recognize it?


session.Save(yourObj)
session.Update(yourObj)
session.SaveOrUpdate(yourObj)
session.Delete(yourObj)

I think, yes ... nh may have a chance to recognize it.


>
> #4 is where I am stuck with Identity Map pattern.  Basically, Fowler's
> implementation in the book is a basic implementation where the objects
> are stored in ArrayList and the containment is checked on .net object
> reference equality.  If you had a million objects, let's say, that
> won't be efficient obviously.  But leaving performance/scalability
> concerns out of the window for now, how does NHibernate deal with
> object equality?


internally NH are using POID or Reference equal depending on the state of
the obj, BTW the equality is not only a NH matter, you should implement your
concept of equality (for example if you want use an HashSet or a
Dictionary).



> Does it compare by certain id field/property on the objects or via
> value comparison? or something else?  Or is that left to the client
> side code to deal with?


See above.

A good place where you can find a lot of answer is "NHibernate in Action"
book.

-- 
Fabio Maulo

--~--~---------~--~----~------------~-------~--~----~
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