NHibernate, each property is filled with a different select statement
Posted
by Eitan
on Stack Overflow
See other posts from Stack Overflow
or by Eitan
Published on 2010-05-12T09:30:28Z
Indexed on
2010/05/12
9:34 UTC
Read the original article
Hit count: 257
I'm retrieving a list of nhibernate entites which have relationships to other tables/entities. I've noticed instead of NHibernate performing JOINS and populating the properties, it retrieves the entity and then calls a select for each property. For example if a user can have many roles and I retrieve a user from the DB, Nhibernate retrieves the user and then populates the roles with another select statement. The problem is that I want to retrieve oh let's say a list of products which have various many-to-many relationships and relationships to items which have their own relationships. In the end I'm left with over a thousand DB calls to retrieve a list of 30 products.
Thanks.
I've also set default lazy loading to false because whenever I save the list of entities to a session, I get an error when trying to retrieve it on another page: LazyInitializationException: could not initialize proxy
If anybody could shed any light I would truly appreciate it.
Thanks.
Eitan
© Stack Overflow or respective owner