-->
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.  [ 1 post ] 
Author Message
 Post subject: Why Hibernate query takes much longer than normal sql
PostPosted: Mon Dec 05, 2011 10:06 am 
Newbie

Joined: Mon Dec 05, 2011 9:51 am
Posts: 1
Hi, I have some problem.

I use ordinary queries hiberanta on tables, that are not entity.
And when I creat SQL cuery using hibernate, this query take long long time more than the same query fired in sql editor ??

String queryStr = "select "
+ " COUNT(*) AS liczba_dekl, "
+ " coalesce( sum(coalesce(kwota_deklaracja_1, kwota_deklaracja_2, '0')), 0) AS suma_dekl "
+ " FROM bs_kontakt k"
+ " WHERE k.id_operator = :idOperator and k.id_produkt = :idProdukt "
+ " AND k.id_typ_kontakt = 1 AND k.data_kontakt BETWEEN :dateFrom AND :dateTo "
+ " AND (kwota_deklaracja_1 IS NOT NULL OR kwota_deklaracja_2 IS NOT NULL )";

Query query = this.getSession().createSQLQuery(queryStr);
query.setDate("dateFrom", dateFrom);
query.setDate("dateTo", dateTo);
query.setBigInteger("idProdukt", idProduct);
query.setBigInteger("idOperator", idWorker);

Map<String, Object> result = new HashMap<String, Object>();

List<Map<String, Object>> resultQuery = query.setResultTransformer(Criteria.ALIAS_TO_ENTITY_MAP).list();
if(resultQuery != null && !resultQuery.isEmpty() && resultQuery.get(0) != null )
{
return resultQuery.get(0);
}

return result;

Could you tell my wher is the problem ??
Why hibernate query is taking so long ??


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

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.