-->
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: CreateCriteria slow performance
PostPosted: Tue Mar 17, 2009 2:20 pm 
Newbie

Joined: Wed Aug 13, 2008 10:00 am
Posts: 7
Hibernate version:2.0.1.4000

Hi,

I have a class(EPLIGAF) which schema is from a linked server to a db2 database.
When I query the table from that class using CreateCriteria everything works but very slow compared to the other methods(CreateQuery and CreateSQLQuery).

CreateCriteria(works slow):

IList<EPLIGAF> list = NHibernateSession.Current.CreateCriteria(typeof(EPLIGAF))
.Add(Restrictions.Eq("Marca", "OC")).List<EPLIGAF>();

CreateQuery(works fast):

IList<EPLIGAF> list = NHibernateSession.Current.CreateQuery("from EPLIGAF ep where ep.Marca = 'OC'").List<EPLIGAF>();

CreateSQLQuery(works fast):

IList<EPLIGAF> list = NHibernateSession.Current.CreateSQLQuery("select LGMRC1 as Marca,LGART1 as Artigo from AS400.S65F18FB.EPLBF01.EPLIGAF where LGMRC1 = 'OC'").SetResultTransformer(Transformers.AliasToBean(typeof(EPLIGAF))).List<EPLIGAF>();

This is very strange and I have no idea of what's happening.
Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 18, 2009 3:31 am 
Expert
Expert

Joined: Thu Dec 14, 2006 5:57 am
Posts: 1185
Location: Zurich, Switzerland
Enable sql logging in hibernate (show_sql=true in the config) and check the generated sql statements. Maybe the fetch mode is different for the queries (join vs. subselect).

_________________
--Wolfgang


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 18, 2009 5:31 am 
Newbie

Joined: Wed Aug 13, 2008 10:00 am
Posts: 7
Hi,

I found out the problem.
I set type="string" for both properties of EPIGLAF class. This was causing the low performance when CreateCriteria was setting the parameters in the where clause. After I set type="AnsiString" CreateCriteria was as fast as the other methods.

Maybe someone can explain why this happens.

Thanks.

EDIT:http://forum.hibernate.org/viewtopic.php?t=969029&view=next&sid=ab29f803e13db0737f69174fcb7ecdeb


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.