Example usage for org.hibernate Query setParameterList

List of usage examples for org.hibernate Query setParameterList

Introduction

In this page you can find the example usage for org.hibernate Query setParameterList.

Prototype

Query<R> setParameterList(int position, Object[] values);

Source Link

Usage

From source file:com.spstudio.modules.member.dao.impl.MemberAssetDAOImpl.java

@Override
public boolean removeAssetList(List<String> assetIdList) {
    String hql = "update MemberAsset set deleteFlag = 1, lastUpdateDate = :updateDate where memberAssetId in :asset_ids";
    Query query = sessionFactory.getCurrentSession().createQuery(hql);
    query.setParameter("updateDate", new Date(System.currentTimeMillis()));
    query.setParameterList("asset_ids", assetIdList);
    int result = query.executeUpdate();
    return (result > 0);
}

From source file:com.spstudio.modules.member.dao.impl.MemberDAOImpl.java

@Override
public boolean removeMemberList(List<String> memberIdList) {
    String hql = "update Member set deleteFlag = 1, lastUpdateDate = :updateDate where memberId in :member_ids";
    Query query = sessionFactory.getCurrentSession().createQuery(hql);
    query.setParameter("updateDate", new Date(System.currentTimeMillis()));
    query.setParameterList("member_ids", memberIdList);
    int result = query.executeUpdate();
    return (result > 0);
}

From source file:com.spstudio.modules.product.dao.impl.ProductDAOImpl.java

@Override
public boolean removeProductList(List<String> idList, String updater) {
    String hql = "update Product set deleteFlag = 1, lastUpdateDate = :updateDate, lastUpdateBy = :updater where productId in :product_ids";
    Query query = sessionFactory.getCurrentSession().createQuery(hql);
    query.setParameter("updateDate", new java.sql.Date(System.currentTimeMillis()));
    query.setParameter("updater", updater);
    query.setParameterList("product_ids", idList);
    int result = query.executeUpdate();
    return (result > 0);
}

From source file:com.spstudio.modules.product.dao.impl.ProductDAOImpl.java

@Override
public boolean removeProductPackageList(List<String> ids, String user) {
    String hql = "update ProductPackage set deleteFlag = 1, lastUpdateDate = :updateDate, lastUpdateBy = :updater where productPackageId in :ids";
    Query query = sessionFactory.getCurrentSession().createQuery(hql);
    query.setParameter("updateDate", new java.sql.Date(System.currentTimeMillis()));
    query.setParameter("updater", user);
    query.setParameterList("ids", ids);
    int result = query.executeUpdate();
    return (result > 0);
}

From source file:com.spstudio.modules.sales.dao.impl.SaleDAOImpl.java

@Override
public boolean removeSalesRecords(List<String> salesIdList) {
    String hql = "update Sales set deleteFlag = 1, lastUpdateDate = :updateDate where saleId in :sale_ids";
    Query query = sessionFactory.getCurrentSession().createQuery(hql);
    query.setParameter("updateDate", new Date(System.currentTimeMillis()));
    query.setParameterList("sale_ids", salesIdList);

    int result = query.executeUpdate();
    return (result > 0);
}

From source file:com.spstudio.modules.sp.dao.impl.ServiceProviderDAOImpl.java

@Override
public boolean removeServiceProviderList(List<String> spIdList) {
    String hql = "update ServiceProvider set deleteFlag = 1, lastUpdateDate = :updateDate where serviceProviderId in :sp_ids";
    Query query = sessionFactory.getCurrentSession().createQuery(hql);
    query.setParameter("updateDate", new Date(System.currentTimeMillis()));
    query.setParameterList("sp_ids", spIdList);
    int result = query.executeUpdate();
    return (result > 0);
}

From source file:com.square.adherent.noyau.dao.implementations.contrat.ContratDaoImpl.java

License:Open Source License

@SuppressWarnings("unchecked")
@Override//from  ww w . jav a 2s .  c om
public List<GarantieBeneficiaireDto> getListeBeneficiairesFromContrats(List<Long> listeUidContrats,
        Long uidAssure, boolean filtrerContratEnCOurs) {
    final StringBuffer requete = new StringBuffer("select uidBeneficiaire, contrat.id, role.id, role.libelle ");
    requete.append("from Garantie where ");
    if (listeUidContrats != null && listeUidContrats.size() > 0) {
        requete.append("contrat.id in (:listeUidContrats) and ");
    }
    if (filtrerContratEnCOurs) {
        requete.append("statut.id = :idStatutGarantieEnCours and ");
    }
    requete.append("contrat.isVisible = true and isVisible = true and ");
    requete.append("uidAssure = :uidAssure order by statut.ordre, role.ordre");
    final Query query = createQuery(requete.toString());
    if (listeUidContrats != null && listeUidContrats.size() > 0) {
        query.setParameterList("listeUidContrats", listeUidContrats);
    }
    if (filtrerContratEnCOurs) {
        query.setLong("idStatutGarantieEnCours", adherentMappingService.getIdStatutGarantieEnCours());
    }

    query.setLong("uidAssure", uidAssure);
    final List<Object[]> listResult = query.list();
    final List<GarantieBeneficiaireDto> listeBeneficiaires = new ArrayList<GarantieBeneficiaireDto>();
    final List<IdsBeneficiaireContrat> listeIdsBenefsContrats = new ArrayList<IdsBeneficiaireContrat>();
    if (listResult != null && listResult.size() > 0) {
        for (Object[] result : listResult) {
            final Long idBenef = (Long) result[0];
            final Long idContrat = (Long) result[1];
            final IdsBeneficiaireContrat idBenefContrat = new IdsBeneficiaireContrat();
            idBenefContrat.setIdBenef(idBenef);
            idBenefContrat.setIdContrat(idContrat);
            if (!listeIdsBenefsContrats.contains(idBenefContrat)) {
                final GarantieBeneficiaireDto benef = new GarantieBeneficiaireDto();
                benef.setIdBenef(idBenef);
                benef.setIdContrat(idContrat);
                benef.setRole(new IdentifiantLibelleDto((Long) result[2], String.valueOf(result[3])));
                listeBeneficiaires.add(benef);
                listeIdsBenefsContrats.add(idBenefContrat);
            }
        }
    }
    return listeBeneficiaires;
}

From source file:com.square.adherent.noyau.dao.implementations.contrat.GarantieBaremeDaoImpl.java

License:Open Source License

private void setParamQuery(Query query, GarantieBaremeCriteresDto criteres) {
    if (criteres.getGarantie() != null) {
        query.setString("garantie", criteres.getGarantie());
    }/*from www .j av  a2 s .  c  o m*/
    if (criteres.getGarantieGestion() != null) {
        query.setString("garantieGestion", criteres.getGarantieGestion());
    }
    if (criteres.getProduitGestion() != null) {
        query.setString("produitGestion", criteres.getProduitGestion());
    }
    if (criteres.getContrat() != null) {
        query.setString("numeroContrat", criteres.getContrat());
    }
    if (criteres.getEidTarifType() != null) {
        query.setString("eidTarifType", criteres.getEidTarifType());
    }
    if (criteres.getEidTypePayeur() != null) {
        query.setString("eidTypePayeur", criteres.getEidTypePayeur());
    }
    if (criteres.getUidAssure() != null) {
        query.setLong("uidAssure", criteres.getUidAssure());
    }
    if (criteres.getIdRoleGarantie() != null) {
        query.setLong("idRole", criteres.getIdRoleGarantie());
    }
    //        if (criteres.getDateEffet() != null) {
    //            query.setCalendar("dateEffet", criteres.getDateEffet());
    //        }
    if (criteres.getDateDebut() != null) {
        query.setCalendar("dateDebut", criteres.getDateDebut());
    }
    if (criteres.getDateFin() != null) {
        query.setCalendar("dateFin", criteres.getDateFin());
    }
    if (criteres.getListeIdsBareme() != null && criteres.getListeIdsBareme().size() > 0) {
        query.setParameterList("listeIdsBareme", criteres.getListeIdsBareme());
    }
}

From source file:com.square.adherent.noyau.dao.implementations.personne.PersonneDaoImpl.java

License:Open Source License

/**
 * {@inheritDoc}//from   w ww  . ja  v  a  2s . c o  m
 */
public List<Long> getListePersonnesNotificationSmsByCriteres(CriteresPersonnesNotificationSmsDto criteres) {
    // Construction de la requte
    final StringBuffer requete = new StringBuffer("SELECT distinct l.decompte_assure_uid ")
            .append("FROM data_decompte l ")
            .append("INNER JOIN data_option o ON (l.decompte_assure_uid = o.option_personne_uid and o.option_type_uid = :idTypeOptionSms"
                    + " and o.option_top_actif = true) ")
            .append("WHERE ( ")
            .append("SELECT sum(l2.decompte_lig_remb_compl) as montant_total FROM data_decompte l2 ")
            .append("WHERE l2.decompte_origine_uid not in (:listeOriginesDesactivees) ")
            .append("AND l2.decompte_date_reglement = :datePaiement ")
            .append("AND l2.decompte_assure_uid = l.decompte_assure_uid ").append(") >= :montantMinimal ")
            .append("AND decompte_origine_uid not in (:listeOriginesDesactivees) ");

    final Query query = createSqlQuery(requete.toString());
    query.setCalendar("datePaiement", criteres.getDateReglement());
    query.setFloat("montantMinimal", criteres.getMontantMinimal());
    query.setLong("idTypeOptionSms", adherentMappingService.getIdTypeOptionEnvoiSms());
    query.setParameterList("listeOriginesDesactivees",
            adherentMappingService.getListeOriginesDecomptesExcluesEnvoiSms());

    // on mappe les resultats dans des dtos
    final List<Long> liste = new ArrayList<Long>();
    for (Object item : query.list()) {
        if (item instanceof Long) {
            liste.add((Long) item);
        } else if (item instanceof BigInteger) {
            liste.add(((BigInteger) item).longValue());
        }
    }
    return liste;
}

From source file:com.square.adherent.noyau.dao.implementations.prestation.RelevePrestationDaoImpl.java

License:Open Source License

@Override
public List<Long> getCandidatsEnvoiRelevesPrestationEmail(int firstResult, int maxResult,
        List<Long> listeIdsExclus, int nbJoursDifferesEnvoiMail, Long idNatureConnexionEspaceAdherent,
        Long idOptionRelevePresta) {
    final StringBuffer requete = new StringBuffer("select distinct (releve_personne_uid) ");
    completerRequeteEnvoiRelevesPrestationEmail(requete, nbJoursDifferesEnvoiMail,
            idNatureConnexionEspaceAdherent, idOptionRelevePresta);
    if (listeIdsExclus != null && listeIdsExclus.size() > 0) {
        requete.append(" and releve_personne_uid not in (:listeIdsExclus)");
    }/* w w w  . ja  va 2s . c o  m*/
    final Query query = createSqlQuery(requete.toString());
    query.setFirstResult(firstResult);
    query.setMaxResults(maxResult);
    final Calendar today = Calendar.getInstance();
    final int jour = today.get(Calendar.DAY_OF_MONTH) - nbJoursDifferesEnvoiMail;
    today.set(Calendar.DAY_OF_MONTH, jour);
    query.setCalendar("dateMaxImpressionParam", today);
    query.setLong("nature", idNatureConnexionEspaceAdherent);
    query.setLong("option", idOptionRelevePresta);
    if (listeIdsExclus != null && listeIdsExclus.size() > 0) {
        query.setParameterList("listeIdsExclus", listeIdsExclus);
    }
    final List<Long> liste = new ArrayList<Long>();
    for (Object item : query.list()) {
        if (item instanceof Long) {
            liste.add((Long) item);
        } else if (item instanceof BigInteger) {
            liste.add(((BigInteger) item).longValue());
        }
    }
    return liste;
}