Hi - I also have many collections on some of my domain objects.

Pros:
1) Step through the domain model using dot-notation without any extra
work on your part.
2) If find that querying against the model is easier, compared to
compairing identifiers directly.
3) Insert and removal of entities is done automatically using the
cascade="all-delete-orphan" option on the collections.

Cons:
1) You have to consider how you load the data. You can very easily
generate a lot SELECTs against the database when traversing the domain
model.

I have begun using the MultiCriteria to load many objects in one go to
the database and then do additional filtering on the web-server. That
way I can have my collections set to lazy=true and then use
FetchMode.Join when I need a collection to be loaded together with the
parent object. I also tend to load objects from the "leaf" objects
even though I need to use the root of the object hierarchy.

I should say that my web applications live in an environment where we
are not allowed to use the Session, thus we are currently forced to
some data on every postback. If you are developing web apps and are
allowed to use some storage on the web-server side you might be able
to live with a few more hits on the database when retrieving objects.

Hope it helps
Thomas

On 18 Jun., 21:27, brendanjerwin <[email protected]> wrote:
> I'm trying to decide on a course of action. Currently, I tend to have
> a fairly large number of collections hanging off my Domain Models:
>
> Organization.Locations
>
> I'm starting to suspect, though, that another pattern might be better:
>
> LocationDao.GetLocationsByParentOrganization(parentOrganization)
>
> Does anyone have any thoughts on these 2 approaches? I like the
> discoverability of the "hanging collections" approach, but I'm worried
> about what it will do with lazy loading...
>
> Thanks for any insight (or links to insight).
--~--~---------~--~----~------------~-------~--~----~
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