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 ??
|