I am working on a system that has Bill Of Materials (BOM) which
contains about 1000-3000 parts organized in a hierarchy about 10
levels deep. The system was using Typed Datasets but I have converterd
parts of it to use an object model and NHibernate for persistance.

The problem is that the NHibernate version is currently much slower
than the dataset version because of the time it takes to load a BOM
into memory. In the old system the entire BOM is loaded into a dataset
in less than a second using a single SELECT (then there is of course a
lot of ugly code working with the dataset in-memory).

Now in the NHibernate version the BOM is loaded as a root entity which
has a persistent collection of its parts which are entities of the
same class and they have collection of their parts etc. This causes
the loading to happen with one SELECT per collection load. I have read
the performance part of the reference docs and have added "batch-size"
to get more collections loaded with each level and it helped some but
it is still generating a lot of SELECT since the BOM is so large and
have lots of levels. Using a very large batch-size does not seem to
work either....

It is quite easy to make a special query using a single SELECT to get
all the objects in the BOM back in a single list but then I loose the
hierarchical organization since the collection of children in each
object are not loaded and when the collections are accessed they will
each generate a new SELECT to get filled anyway.

I thought about making a special repository method to load all objects
in a single list with a single SELECT and then using some sorting code
to put the objects from this list into each BOM objects childrens
collection. The problem with this approach is that since the children
collection list is a mapped persistant collection the proxy object
will fill the collection when I access it. I would have to find some
way to temporarily bybass the proxy object's collection loading and
fill the childrens collection manually but I don't know how... or am I
on the wrong track here? Is there some other way to fill all
collections in a single SELECT but still have them mapped so they
cacade save etc.?

Another problem is the deletion of a BOM. What happens is that first a
lot of SELECT is generated to sort out which objects belong to the BOM
and then a lot of DELETE is generated. It would be more effective if I
could do a single DELETE and then find and evict any BOM objects that
might be loaded in the session for the BOM being deleted. Could this
be done?




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