-->
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.  [ 6 posts ] 
Author Message
 Post subject: Can NHibernate load the result of a query per object?
PostPosted: Thu May 24, 2007 2:24 pm 
Beginner
Beginner

Joined: Tue Aug 23, 2005 8:15 am
Posts: 45
IList<Test> result = criteria.List<Test>();

return ALL objects (fully and partially depends on laziness) correspond the query.

Can I ask NHibernate to give me only 1 next object of the result?
(Then I would like to use the object, call session.Evict(obj)
to free memory and ask NHibernate for next one).

Best regards,
Sergey


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 24, 2007 2:36 pm 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
No, NHibernate does not support this feature (scrollable result sets).


Top
 Profile  
 
 Post subject: Sergey, is it difficult to implement it by myself?
PostPosted: Thu May 24, 2007 2:41 pm 
Beginner
Beginner

Joined: Tue Aug 23, 2005 8:15 am
Posts: 45
Are there some architctualy difficulties to implement this?

sergey wrote:
No, NHibernate does not support this feature (scrollable result sets).


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 24, 2007 3:10 pm 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
ADO.NET doesn't support it.


Top
 Profile  
 
 Post subject: it's clear. Oner more question.
PostPosted: Thu May 24, 2007 3:27 pm 
Beginner
Beginner

Joined: Tue Aug 23, 2005 8:15 am
Posts: 45
I deal with some kind of "Object" Data Mining task and try to use NHibernate as object provider. What do you think, is it good choice?
That what I need are: object oriented "select" queries and ability to manage the memory usage used for already selected object.


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 24, 2007 5:46 pm 
Newbie

Joined: Sat Dec 16, 2006 11:10 am
Posts: 2
You can do something like:

Code:
DetachedCriteria crit = DetachedCriteria.For<Test>();
crit.SetMaxResults(1);

// you can also use the Criteria to eager fetch some lazy collections
crit.SetFetchMode("SubTests", FetchMode.Eager);

int i = 0;
while (true) {
  crit.SetFirstResult(i);
  IList<Test> result = RunDetachedCriteria(crit);
  if (result.Count == 0)
    break;
  Test obj = result[0];
  // ... work ...
  EvictObject(obj);
  i++;
}


But it looks somewhat inefficient to me, unless your objects are really huge.

_________________
Fábio Batista
Castle Project PMC Member
Co-founder of Suprifattus


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 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.