NH does much more than simply make database calls. There is entity mapping 1st/2nd level caching change management
and that's the main points. there is also other subtle features of NH. Also ORM's are not really meant for large record sets. I believe I saw 300,000+ records being deleted. This sounds like more of an ETL operation. And comparing how NH and EF can issue the query "delete from [table]" is pointless. Where NH shines is modeling the database to the domain. There are numerous hooks between interceptorts, listeners, cache managment, entity hydration, mapping/query options which allow you to mold NH to your domain (not your domain to NH). The learning curve for NH is steep, I won't argue that. But it is very powerful and flexible. For more examples of what is possible with NH check out blogs.hibernatingrhinos.com, http://ayende.com/Blog/category/510.aspx and http://nhforge.org/ On Aug 12, 9:17 am, "F.B. ten Kate" <[email protected]> wrote: > Ow i in no way intend to call my NHibernate from buttons in an > actually production application. I want to have a repository handle on > those nasty things for me. > > As for me never loading this many enitities... I do actually have to > load these. With the comments regarding the proxy creation or caching, > if i understand correctly proxy's are created for Lazy loading and > things. > > In my first tests (maps not posted here but basically i didnt have an > Entiteit object) the query was also as slow. Or does NHibernate create > proxy's for entity's it will load in the end eitherway? > > Basically the way i "see" it. NHibernate should query for me and put > all the data inside Debiteur objects which are returns as a IList. > > Afaik the Entity framework does the exact same yet for some reason > which i cannot seem to wrap my head around NHibernate takes 19 seconds > to do this... this is the time i'm trying to explain and hopefully > reduce since atm it doesn't make sense to me. > > On 12 aug, 15:01, Fabio Maulo <[email protected]> wrote: > > > proxy creation and cached proxi. > > > 2009/8/12 F.B. ten Kate <[email protected]> > > > > Okay, fiddled around some more, Now i create a new Session when i hit > > > the button. which i close and then dispose when done. > > > > Next time i hit the button it creates a new Session again, now i can > > > reproduce the slowness. Every singletime i hit the button it takes 19+ > > > seconds to execute everything. What would typically be the reason for > > > this? Because to me it would make no sense for the Session to be slow > > > the first time it executes this query, but then if the same Session > > > executes the SAME query things are executed as fast as they should. > > > > On 12 aug, 14:47, "F.B. ten Kate" <[email protected]> wrote: > > > > I've posted my mappings and configuration already. Same goes for teh > > > > code, only thing i didn't post is the Classes which i map too. Ill > > > > post those now > > > > > using System; > > > > using System.Collections.Generic; > > > > using System.Linq; > > > > using System.Text; > > > > > namespace NHibernate2 > > > > { > > > > public class tEntiteit > > > > { > > > > private Int32 id; > > > > private string name; > > > > private IList<Debiteur> debiteurs; > > > > > public virtual IList<Debiteur> Debiteurs > > > > { > > > > set > > > > { > > > > debiteurs = value; > > > > } > > > > get > > > > { > > > > return debiteurs; > > > > } > > > > } > > > > > public virtual Int32 Id > > > > { > > > > set > > > > { > > > > id = value; > > > > } > > > > get > > > > { > > > > return id; > > > > } > > > > } > > > > public virtual string Name > > > > { > > > > set > > > > { > > > > name = value; > > > > } > > > > get > > > > { > > > > return name; > > > > } > > > > } > > > > } > > > > > } > > > > > using System; > > > > using System.Collections.Generic; > > > > using System.Text; > > > > > namespace NHibernate2 > > > > { > > > > public class Debiteur > > > > { > > > > private Int32 id; > > > > private string name; > > > > private string sorteernaam; > > > > private DateTime datumwijzigen; > > > > private int actiefneeja; > > > > private tEntiteit entiteit; > > > > > public virtual Int32 Id > > > > { > > > > set > > > > { > > > > id = value; > > > > } > > > > get > > > > { > > > > return id; > > > > } > > > > } > > > > public virtual tEntiteit Entiteit > > > > { > > > > set > > > > { > > > > entiteit = value; > > > > } > > > > get > > > > { > > > > return entiteit; > > > > } > > > > } > > > > public virtual Int32 ActiefNeeJa > > > > { > > > > set > > > > { > > > > actiefneeja = value; > > > > } > > > > get > > > > { > > > > return actiefneeja; > > > > } > > > > } > > > > public virtual string Name > > > > { > > > > set > > > > { > > > > name = value; > > > > } > > > > get > > > > { > > > > return name; > > > > } > > > > } > > > > public virtual string Sorteernaam > > > > { > > > > set > > > > { > > > > sorteernaam = value; > > > > } > > > > get > > > > { > > > > return sorteernaam; > > > > } > > > > } > > > > public virtual DateTime DatumWijziging > > > > { > > > > set > > > > { > > > > datumwijzigen = value; > > > > } > > > > get > > > > { > > > > return datumwijzigen; > > > > } > > > > } > > > > } > > > > > } > > > > > On 12 aug, 14:43, Carlos cubas <[email protected]> wrote: > > > > > > Maybe if you show us your configuration file and mapping files we can > > > help more. > > > > > > -Carlos > > > > > > Practice makes perfect, but if no one is perfect, why practice? > > > > > > > Date: Wed, 12 Aug 2009 05:26:29 -0700 > > > > > > Subject: [nhusers] Re: NHIbernate performance vs Entity Framework > > > > > > From: [email protected] > > > > > > To: [email protected] > > > > > > > Changed the code a little, i'm now creating one session, and one > > > > > > factory on the Load. However i use a button_click to trigger the > > > > > > actual querying.. > > > > > > > First time i click el button it's slow (both the msgbox timer shows > > > 21 > > > > > > seconds and profiler tells me 19 seconds) but the second time i hit > > > > > > the button (even after clearing th SQL Cache) it runs in less then 5 > > > > > > seconds. > > > > > > > So it clearly has something to do with the creating of objects or > > > > > > something. I'm kind of clueless as to what i'm doing wrong to cause > > > > > > the horrible performance i'm having on the first calling > > > > > > > On 12 aug, 14:15, "F.B. ten Kate" <[email protected]> wrote: > > > > > > > Ow, little extra info, it's 390000 Records i'm querying, which > > > > > > > obviously is kinda alot. > > > > > > > > On 12 aug, 14:12, "F.B. ten Kate" <[email protected]> wrote: > > > > > > > > > Like i said, the "timer" is in SQL Profiler. In otherwords not > > > > > > > > in > > > the > > > > > > > > code, but i also have the following bits in there to compare. > > > > > > > > > DateTime start = DateTime.Now; > > > > > > > > IList<Debiteur> lijst = > > > > > > > > session.CreateCriteria(typeof > > > > > > > > (Debiteur)).List<Debiteur>(); > > > > > > > > DateTime stop = DateTime.Now; > > > > > > > > dataGridView1.DataSource = lijst; > > > > > > > > > MessageBox.Show((stop-start).Seconds +"."+ (stop- > > > > > > > > start).Milliseconds); > > > > > > > > > Meaning i start the timer AFTER the session has been created, > > > > > > > > and > > > > > > > > start the "query" if i am getting this. the NHibernate project > > > atm > > > > > > > > takes 26 seconds to do this (this is with another enitity added > > > with > > > > > > > > Lazyloading, without this entitity it was +- 21 seconds) EF does > > > the > > > > > > > > same action in +- 5 seconds. Which leads me to believe the > > > problem > > > > > > > > lies in the execution of the SQL. > > > > > > > > > On 12 aug, 14:07, Paco Wensveen <[email protected]> wrote: > > > > > > > > > > The sql is not executing slowly, the building of the > > > sessionfactory is > > > > > > > > > slow. Start your timer after buildsessionfactory and compare > > > again. > > > > > > > > > > On Wed, Aug 12, 2009 at 2:01 PM, F.B. ten Kate< > > > [email protected]> wrote: > > > > > > > > > > > Yes i am atm, since it's just a quit check to run a query, > > > but would > > > > > > > > > > this explain the SQL executing this slowly? > > > > > > > > > > > I know i'm not using any "best" practises and things, this > > > > > > > > > > is > > > the > > > > > > > > > > first thing im doing with both NHibernate and EF. > > > > > > > > > > > Here is the code running it. > > > > > > > > > > > Configuration cfg = new Configuration(); > > > > > > > > > > cfg.Configure(); > > > > > > > > > > cfg.AddAssembly(typeof(Debiteur).Assembly); > > > > > > > > > > > ISessionFactory factory = > > > cfg.BuildSessionFactory(); > > > > > > > > > > ISession session = factory.OpenSession(); > > > > > > > > > > > IList<Debiteur> lijst = > > > session.CreateCriteria(typeof > > > > > > > > > > (Debiteur)).List<Debiteur>(); > > > > > > > > > > > dataGridView1.DataSource = lijst; > > > > > > > > > > > On 12 aug, 13:22, Kim Johansson <[email protected]> > > > wrote: > > > > > > > > > >> Are you > > ... > > read more » --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
