-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Problem persisting a huge amount of data with 3 Entities
PostPosted: Mon Jan 08, 2007 10:59 am 
Newbie

Joined: Mon Jan 08, 2007 10:29 am
Posts: 3
Dear Hibernate/NHibernate community

I have the following problem with persisting a huge collection of data:

My object-model looks like this:

Image

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


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 08, 2007 5:57 pm 
Contributor
Contributor

Joined: Sat Sep 24, 2005 11:25 am
Posts: 198
Execute the following HQL

Code:
select blog from Post post
left join fetch post.Comments
left join fetch post.Blog blog


Where:
Blog is Entity1
Post is Entity2
Comment is Entity3

This results in a single query.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 09, 2007 8:06 am 
Newbie

Joined: Tue Apr 25, 2006 8:58 am
Posts: 1
Will the entities beeing persisted in the proxy by executing a HQL ?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.