Dear Hibernate/NHibernate community
I have the following problem with persisting a huge collection of data:
My object-model looks like this:
I want to load
all the data of one Entity1 including its childs Entity2 and its grandchilds Entity3 in the memory and if possible with a maximum of 3 select statements.
performing a
session.Load<Entity1>(new Entity1_Id(1));
results in executing
one select statement for Entity1,
one select statement for Entity2
but
50 select statements for Entity3.
I know there is the solution to use the batch-size parameter for child/grandchild entities but this is not really a solution for my project
since the batched-queries size will be too big to execute. (execution of too many "OR" statements)
In my realworld application there could be over 10.000 grandchild datarows per child.
And reducing the batch size returns to execute too many queries.
I tried an approach by additionally hanging the Entity3 directly under Entity1 (with lazy=false) witch results in executing only 3 queries (half of the work done)
but this results in the fact, that Entity2 does not know about its childs collections of Entity3...
recapitulation:
3 depending Entities witch are to be loaded in 3 statements with resolved relationships.
Any approach for this ?
Hibernate version:1.2.0
Mapping documents:
http://www.intex.de/nhibernate/NHibernate.hbm.xml
Name and version of the database you are using:
MSSQL Server 2000
The generated SQL:
// Entity1 (1 result)
exec sp_executesql N'SELECT entity1.......
// Entity2 (50 results)
exec sp_executesql N'SELECT entity2_.......
// Entity3 as often as Entity2 exists
exec sp_executesql N'SELECT entity3......
exec sp_executesql N'SELECT entity3......
exec sp_executesql N'SELECT entity3......
exec sp_executesql N'SELECT entity3......
exec sp_executesql N'SELECT entity3......
.
.
50 times
or batched statements for Entity3