|
|
@@ -1,13 +1,11 @@
|
|
|
package powerage.dao;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
|
|
|
import commons.utility.MutableHolder;
|
|
|
|
|
|
-import jakarta.persistence.EntityManager;
|
|
|
-import jakarta.persistence.TypedQuery;
|
|
|
-import jakarta.transaction.Transactional;
|
|
|
-import lombok.RequiredArgsConstructor;
|
|
|
+import org.hibernate.SessionFactory;
|
|
|
import org.hibernate.query.Query;
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
@@ -18,7 +16,7 @@ import powerage.entities.Ordine;
|
|
|
import commons.utility.dao.IDAO;
|
|
|
|
|
|
@Repository
|
|
|
-public class OrdineDAO
|
|
|
+public class OrdineDAO
|
|
|
extends PowerAgeDAO<Ordine, Long>
|
|
|
implements IDAO<Ordine, Long> {
|
|
|
|
|
|
@@ -32,7 +30,7 @@ public class OrdineDAO
|
|
|
hql.append(" and (c.ragioneSociale like :filter or c.codCliente = :filterExact or a.ragioneSociale = :filterRS or a.codAgente = :filterCA)");
|
|
|
}
|
|
|
|
|
|
- TypedQuery<Long> countQuery = currentSession()
|
|
|
+ Query<Long> countQuery = currentSession()
|
|
|
.createQuery("select count(o.idOrdine) " + hql.toString(), Long.class);
|
|
|
if (idAgente != 0)
|
|
|
countQuery.setParameter("idAgente", idAgente);
|
|
|
@@ -42,8 +40,7 @@ public class OrdineDAO
|
|
|
countQuery.setParameter("filterRS", filter);
|
|
|
countQuery.setParameter("filterCA", filter);
|
|
|
}
|
|
|
-
|
|
|
- rowCount.value = (countQuery.getSingleResult()).intValue();
|
|
|
+ rowCount.value = countQuery.uniqueResult().intValue();
|
|
|
|
|
|
Query<Ordine> query = currentSession()
|
|
|
.createQuery(hql.toString() + " order by o.dataOrdine desc", Ordine.class);
|
|
|
@@ -62,7 +59,6 @@ public class OrdineDAO
|
|
|
return res;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
public List<Ordine> getOrdiniNuovi(int idAgente, String filter, int iDisplayStart, int iDisplayLength, int iSortCol_0, String sSortDir_0, MutableHolder<Integer> rowCount) {
|
|
|
boolean tx = startTransaction();
|
|
|
|
|
|
@@ -106,19 +102,15 @@ public class OrdineDAO
|
|
|
|
|
|
public List<Ordine> getNewOrders() {
|
|
|
boolean tx = startTransaction();
|
|
|
-
|
|
|
- Query<Ordine> q = currentSession()
|
|
|
- .createQuery("select o from Ordine o where o.stato = :stato", Ordine.class)
|
|
|
+ List<Ordine> res = currentSession()
|
|
|
+ .createQuery("from Ordine o where o.stato = :stato", Ordine.class)
|
|
|
.setParameter("stato", "N")
|
|
|
- ;
|
|
|
-
|
|
|
- List<Ordine> res = q.list();
|
|
|
+ .list();
|
|
|
if (tx)
|
|
|
commit();
|
|
|
return res;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
public Ordine getByIdOrdineAgente(long idAgente, long idOrdineAgente) {
|
|
|
List<Ordine> res = currentSession()
|
|
|
.createQuery("from Ordine o join fetch o.agente a where a.idAgente = :idAgente and o.idOrdineAgente = :idOrdAgente", Ordine.class)
|
|
|
@@ -136,7 +128,7 @@ public class OrdineDAO
|
|
|
|
|
|
boolean tx = startTransaction();
|
|
|
|
|
|
- StringBuilder hql = new StringBuilder("from Ordine o join o.cliente c join o.agente a where 1=1 ");
|
|
|
+ StringBuilder hql = new StringBuilder("from Ordine o join o.cliente c join o.agente a where 1=1 ");
|
|
|
if (beanFiltriOrdine != null) {
|
|
|
if (beanFiltriOrdine.getCbSoloNuovi())
|
|
|
hql.append(" and o.stato = :stato");
|
|
|
@@ -153,9 +145,8 @@ public class OrdineDAO
|
|
|
hql.append(" and o.dataOrdine <= :aData");
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- jakarta.persistence.Query countQuery = currentSession().createQuery("select count(distinct o)" + hql.toString());
|
|
|
-
|
|
|
+ Query<Long> countQuery = currentSession()
|
|
|
+ .createQuery("select count(distinct o) " + hql.toString(), Long.class);
|
|
|
if (beanFiltriOrdine != null) {
|
|
|
if (beanFiltriOrdine.getCbSoloNuovi())
|
|
|
countQuery.setParameter("stato", K_NUOVO);
|
|
|
@@ -172,7 +163,7 @@ public class OrdineDAO
|
|
|
if (beanFiltriOrdine.getaData() != null)
|
|
|
countQuery.setParameter("aData", beanFiltriOrdine.getaData());
|
|
|
}
|
|
|
- Object cnt = ((Number)(countQuery.getSingleResult())).longValue();
|
|
|
+ Object cnt = countQuery.uniqueResult();
|
|
|
if (cnt instanceof Long)
|
|
|
rowCount.value = ((Long) cnt).intValue();
|
|
|
else
|