I mean do the equivalent in HQL or Criteria

2009/3/19 kello <[email protected]>

>
> I actually tried to use such a query and return only the root entity
> only I am not using DAOs but a Repository which directly uses the
> nhibernate session to create a SQL Query. Much simplified It goes
> something like this:
>
>     Dim query = Session.CreateSQLQuery("SELECT * FROM BomLines WHERE
> BomId=foo ORDER BY foo")
>     Dim list = query.List()
>     Return list(0)
>
> What happened was that the children collections were still loaded by a
> SELECT each when traversing the tree from the root entity. I think it
> is because the query only returns a flat list of all the entities, it
> does not load the children collection in each entity?
>
> /Jonas
>
> On Mar 19, 4:13 am, Fabio Maulo <[email protected]> wrote:
> > You can use a similar select you are using in the old system and then you
> > can return only the root from your DAO.BTW 3000 entities in RAM will have
> > some cost.
> >
> > 2009/3/18 kello <[email protected]>
> >
> >
> >
> >
> >
> >
> >
> > > 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?
> >
> > --
> > Fabio Maulo- Hide quoted text -
> >
> > - Show quoted text -
> >
>


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