List of usage examples for org.hibernate Query setCalendar
@Deprecated @SuppressWarnings("unchecked") default Query<R> setCalendar(String name, Calendar value)
From source file:com.square.adherent.noyau.dao.implementations.contrat.ContratDaoImpl.java
License:Open Source License
@Override @SuppressWarnings("unchecked") public Contrat getContratSantePersonneInactifXMois(Long idPersonne, Calendar dateInactiviteGarantieSante) { final StringBuffer requete = new StringBuffer("select contrat_numero from data_contrat "); requete.append("where data_contrat.contrat_assure_uid = :idPersonne "); requete.append(//from w w w .ja v a 2s. c o m "and data_contrat.contrat_statut_uid <> :idStatutEnCours and data_contrat.contrat_nature_uid = :idNatureSante "); // requete.append("and data_contrat.contrat_adhesion_onum <> 'groupe' "); requete.append( "and data_contrat.contrat_date_resiliation < now() and data_contrat.contrat_date_resiliation >= :dateInactiviteGarantieSante "); requete.append("and data_contrat.contrat_visible = true "); requete.append("group by contrat_numero "); final Query crit = createSqlQuery(requete.toString()); crit.setLong("idPersonne", idPersonne); crit.setLong("idStatutEnCours", adherentMappingService.getIdStatutContratEnCours()); crit.setLong("idNatureSante", adherentMappingService.getIdNatureContratSante()); crit.setCalendar("dateInactiviteGarantieSante", dateInactiviteGarantieSante); final List<String> resultats = (ArrayList<String>) crit.list(); return resultats.size() == 1 ? ((Contrat) getContratByNumero(resultats.get(0))) : null; }
From source file:com.square.adherent.noyau.dao.implementations.contrat.ContratDaoImpl.java
License:Open Source License
@Override @SuppressWarnings("unchecked") public List<ProduitCollectifAdherentDto> getListeProduitsCollectifsAdherent( ProduitCollectifAdherentCriteresDto criteres, Long idRoleGarantieAssure, Long idStatutGarantieEnCours, Long idStatutGarantieFutur) { final StringBuffer requete = new StringBuffer( "select g.libelleProduitGestion, g.libelleGarantieGestion, g.codeTarif, g.montantSouscrit "); requete.append(", CAST(sum(CASE g.statut.id WHEN :idStatutGarantieEnCours THEN 1 ELSE 0 END) as integer) "); requete.append("from Contrat cg, Garantie g, Contrat cp "); requete.append("where substring(cg.identifiantExterieur,1,13) = substring(cp.identifiantExterieur,1,13) "); requete.append("and g.contrat.id = cp.id "); requete.append("and g.role.id = :idRoleGarantieAssure "); requete.append("and g.statut.id in (:idStatutGarantieEnCours, :idStatutGarantieFutur) "); if (criteres.getPopulation() != null) { requete.append("and g.libellePopulation = :population "); }/* www. j av a2 s .c o m*/ if (criteres.getContrat() != null) { requete.append("and cg.numeroContrat = :numeroContrat "); } if (criteres.getUidEntreprise() != null) { requete.append("and cg.uidSouscripteur = :uidSouscripteur "); } if (criteres.getDateEffet() != null) { requete.append(" and g.dateAdhesion <= :dateEffet"); requete.append(" and (g.dateResiliation is null or g.dateResiliation >= :dateEffet)"); } requete.append( "group by g.libelleProduitGestion, g.libelleGarantieGestion, g.codeTarif, g.montantSouscrit "); final Query query = createQuery(requete.toString()); query.setLong("idRoleGarantieAssure", idRoleGarantieAssure); query.setLong("idStatutGarantieEnCours", idStatutGarantieEnCours); query.setLong("idStatutGarantieFutur", idStatutGarantieFutur); if (criteres.getUidEntreprise() != null) { query.setLong("uidSouscripteur", criteres.getUidEntreprise()); } if (criteres.getContrat() != null) { query.setString("numeroContrat", criteres.getContrat()); } if (criteres.getPopulation() != null) { query.setString("population", criteres.getPopulation()); } if (criteres.getDateEffet() != null) { query.setCalendar("dateEffet", criteres.getDateEffet()); } final List<Object[]> rows = query.list(); final List<ProduitCollectifAdherentDto> liste = new ArrayList<ProduitCollectifAdherentDto>(); for (Object[] row : rows) { liste.add(new ProduitCollectifAdherentDto((String) row[0], (String) row[1], (String) row[2], (Double) row[3], (Integer) row[4])); } return liste; }
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 ww w . java 2 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.contrat.GarantieDaoImpl.java
License:Open Source License
@Override @SuppressWarnings("unchecked") // TODO manque la table data_provenance public List<InfosProduitDto> getInfosProduits(CriteresInfosProduitsDto criteres) { final StringBuffer requete = new StringBuffer("select garantie_beneficiaire_uid, ").append( "data_garantie.garantie_role_uid, garantie_role_lib, garantie_produit_gestion, garantie_libelle_gestion, ") .append("contrat_frequence_paiement_lib, contrat_moyen_paiement_lib, ") .append("garantie_date_adhesion, garantie_date_resiliation, data_garantie.garantie_famille_uid, data_garantie.garantie_segment_uid, ") .append("garantie_famille_ordre ") .append("from data_garantie inner join data_contrat on contrat_uid = garantie_contrat_uid ") .append("left join dim_garantie_role on data_garantie.garantie_role_uid = dim_garantie_role.garantie_role_uid ") .append("left join dim_garantie_famille on data_garantie.garantie_famille_uid = dim_garantie_famille.garantie_famille_uid ") .append("left join dim_contrat_moyen_paiement on data_contrat.contrat_moyen_paiement_cotis_uid=") .append("dim_contrat_moyen_paiement.contrat_moyen_paiement_uid ") .append("left join dim_contrat_frequence_paiement on ") .append("data_contrat.contrat_frequence_paiement_cotis_uid=dim_contrat_frequence_paiement.contrat_frequence_paiement_uid ") .append("where data_garantie.garantie_statut_uid = :idStatutGarantieEnCours and data_garantie.garantie_visible = true "); if (criteres.getIdContrat() != null) { requete.append(" and contrat_uid = :paramContratUid"); }/*from w w w .java2 s. co m*/ if (criteres.getIdAssure() != null) { requete.append(" and contrat_assure_uid = :paramAssureUid"); } if (criteres.getIdPersonne() != null) { requete.append(" and garantie_beneficiaire_uid = :paramPersonneUid"); } if (criteres.getIdFamille() != null) { requete.append(" and garantie_famille_uid >= :paramFamilleUid"); } if (criteres.getDateDebutDeGarantie() != null) { requete.append(" and garantie_date_adhesion >= :paramDateDebut"); } if (criteres.isHorsProduitsBonus()) { requete.append(" and data_garantie.garantie_famille_uid <> :idFamilleGarantieBonus"); } if (criteres.isFiltreNullSurDateDeFin()) { requete.append(" and (garantie_date_resiliation is null or garantie_date_resiliation >= now())"); requete.append(" and garantie_date_adhesion <= now()"); } else if (criteres.getDateDeFinDeGarantie() != null) { requete.append(" and garantie_date_adhesion <= :paramDateFin"); } requete.append(" order by garantie_role_lib, garantie_famille_ordre"); final Query query = createSqlQuery(requete.toString()); if (criteres.getIdContrat() != null) { query.setLong("paramContratUid", criteres.getIdContrat()); } if (criteres.getIdAssure() != null) { query.setLong("paramAssureUid", criteres.getIdAssure()); } if (criteres.getIdPersonne() != null) { query.setLong("paramPersonneUid", criteres.getIdPersonne()); } if (criteres.getIdFamille() != null) { query.setLong("paramFamilleUid", criteres.getIdFamille()); } if (criteres.getDateDebutDeGarantie() != null) { query.setCalendar("paramDateDebut", criteres.getDateDebutDeGarantie()); } if (!criteres.isFiltreNullSurDateDeFin() && criteres.getDateDeFinDeGarantie() != null) { query.setCalendar("paramDateFin", criteres.getDateDeFinDeGarantie()); } query.setLong("idStatutGarantieEnCours", adherentMappingService.getIdStatutGarantieEnCours()); if (criteres.isHorsProduitsBonus()) { query.setLong("idFamilleGarantieBonus", adherentMappingService.getIdFamilleGarantieBonus()); } final List<Object[]> resultats = (ArrayList<Object[]>) query.list(); final List<InfosProduitDto> listeInfosProduit = new ArrayList<InfosProduitDto>(); for (int i = 0; i < resultats.size(); i++) { final Object[] res = (Object[]) resultats.get(i); // Mapping d'un rsultat dans le dto associ. int j = 0; final InfosProduitDto infoProduit = new InfosProduitDto(); final Object idPersonne = res[j++]; infoProduit.setIdPersonne(idPersonne != null ? Long.valueOf(idPersonne.toString()) : null); final Object idRole = res[j++]; infoProduit.setIdRole(idRole != null ? Long.valueOf(idRole.toString()) : null); // On saute le libell de rle j++; infoProduit.setProduitAia((String) res[j++]); infoProduit.setGarantieAia((String) res[j++]); infoProduit.setFrequenceReglement((String) res[j++]); infoProduit.setModeReglement((String) res[j++]); final Calendar dateEffet = Calendar.getInstance(); dateEffet.setTimeInMillis(((Timestamp) res[j++]).getTime()); infoProduit.setDateEffet(dateEffet); final Calendar dateResiliation = Calendar.getInstance(); final Object objDateResiliation = res[j++]; if (objDateResiliation != null) { dateResiliation.setTimeInMillis(((Timestamp) objDateResiliation).getTime()); infoProduit.setDateResiliation(dateResiliation); } final Object idFamilleGarantie = res[j++]; infoProduit.setIdFamilleGarantie( idFamilleGarantie != null ? Long.valueOf(idFamilleGarantie.toString()) : null); final Object idSegmentGarantieObj = res[j++]; final Long idSegmentGarantie = idSegmentGarantieObj != null ? Long.valueOf(idSegmentGarantieObj.toString()) : null; final boolean isFromContratCollectif = adherentMappingService.getIdSegmentCollectif() .equals(idSegmentGarantie) || adherentMappingService.getIdSegmentCollectifIndividualise().equals(idSegmentGarantie); infoProduit.setIsFromContratCollectif(isFromContratCollectif); final Object ordre = res[j++]; infoProduit.setOrdre(ordre != null ? Integer.valueOf(ordre.toString()) : null); listeInfosProduit.add(infoProduit); } return listeInfosProduit; }
From source file:com.square.adherent.noyau.dao.implementations.personne.PersonneDaoImpl.java
License:Open Source License
/** * {@inheritDoc}//w w w.j a v a 2 s . 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 @SuppressWarnings("unchecked") public List<RelevePrestation> getListeReleveParCriteres( CritereSelectionRelevePrestationDto critereSelectionRelevePrestationDto, Boolean triDesc) { final StringBuffer requete = new StringBuffer( "select distinct(relevePresta) from RelevePrestation relevePresta "); boolean existCritere = false; if (critereSelectionRelevePrestationDto.getIdPersonne() != null) { requete.append("where relevePresta.uidPersonne =:idPersonne "); existCritere = true;//from w w w . j a va 2 s . c o m } if (critereSelectionRelevePrestationDto.getRelevePrestationId() != null) { requete.append(getConditionSeparator(existCritere)).append("relevePresta.id =:idRelevePresta "); existCritere = true; } if (critereSelectionRelevePrestationDto.getEnvoyeMail() != null) { requete.append(getConditionSeparator(existCritere)) .append("relevePresta.envoyeMail =:envoyeMailParam "); existCritere = true; } if (critereSelectionRelevePrestationDto.getAutorisationEnvoiMail() != null) { requete.append(getConditionSeparator(existCritere)) .append("relevePresta.moyenPaiement.autorisationEnvoiMail = :autorisationEnvoiMailParam "); existCritere = true; } if (critereSelectionRelevePrestationDto.getDateMaxImpression() != null) { requete.append(getConditionSeparator(existCritere)) .append("relevePresta.dateImpression <= :dateMaxImpressionParam "); existCritere = true; } if (critereSelectionRelevePrestationDto.getDateMinImpression() != null) { requete.append(getConditionSeparator(existCritere)) .append("relevePresta.dateImpression >= :dateMinImpressionParam "); existCritere = true; } if (triDesc != null && triDesc) { requete.append("order by relevePresta.dateImpression desc"); } else if (triDesc != null && !triDesc) { requete.append("order by relevePresta.dateImpression asc"); } final Query query = createQuery(requete.toString()); query.setFirstResult(0); if (critereSelectionRelevePrestationDto.getNombreMax() != null) { query.setMaxResults(critereSelectionRelevePrestationDto.getNombreMax().intValue()); } if (critereSelectionRelevePrestationDto.getIdPersonne() != null) { query.setLong("idPersonne", critereSelectionRelevePrestationDto.getIdPersonne()); } if (critereSelectionRelevePrestationDto.getRelevePrestationId() != null) { query.setLong("idRelevePresta", critereSelectionRelevePrestationDto.getRelevePrestationId()); } if (critereSelectionRelevePrestationDto.getEnvoyeMail() != null) { query.setBoolean("envoyeMailParam", critereSelectionRelevePrestationDto.getEnvoyeMail().booleanValue()); } if (critereSelectionRelevePrestationDto.getAutorisationEnvoiMail() != null) { query.setBoolean("autorisationEnvoiMailParam", critereSelectionRelevePrestationDto.getAutorisationEnvoiMail().booleanValue()); } if (critereSelectionRelevePrestationDto.getDateMaxImpression() != null) { query.setCalendar("dateMaxImpressionParam", critereSelectionRelevePrestationDto.getDateMaxImpression()); } if (critereSelectionRelevePrestationDto.getDateMinImpression() != null) { query.setCalendar("dateMinImpressionParam", critereSelectionRelevePrestationDto.getDateMinImpression()); } return (List<RelevePrestation>) query.list(); }
From source file:com.square.adherent.noyau.dao.implementations.prestation.RelevePrestationDaoImpl.java
License:Open Source License
/** * {@inheritDoc}//from w w w . jav a2s. co m */ public Integer getNombreCandidatsEnvoiRelevesPrestationEmail(int nbJoursDifferesEnvoiMail, Long idNatureConnexionEspaceAdherent, Long idOptionRelevePresta) { final StringBuffer requete = new StringBuffer("select count (distinct (releve_personne_uid)) "); completerRequeteEnvoiRelevesPrestationEmail(requete, nbJoursDifferesEnvoiMail, idNatureConnexionEspaceAdherent, idOptionRelevePresta); final Query query = createSqlQuery(requete.toString()); 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); return Integer.valueOf(query.uniqueResult().toString()); }
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 ww .j a va 2 s . co 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; }
From source file:com.square.adherent.noyau.dao.implementations.prestation.ReserveBancoDaoImpl.java
License:Open Source License
/** * {@inheritDoc}/* w w w . ja v a 2 s.c om*/ */ @SuppressWarnings("unchecked") public List<ReserveProduitBancoDto> getListeReservesBancoByAdherent(Long idAdherent) { final StringBuffer requete = new StringBuffer( "select franchise_cotisation_annuelle, franchise_versee_reserve, franchise_debut_periode, "); requete.append("franchise_fin_periode, garantie_date_adhesion "); requete.append("from data_franchise inner join data_garantie on franchise_garantie_uid = garantie_uid "); requete.append("where franchise_personne_uid = :idAdherent "); requete.append("and franchise_fin_periode >= :dateAnneePrecedente "); requete.append("and franchise_debut_periode <= :dateDuJour "); requete.append("order by franchise_debut_periode, franchise_fin_periode"); final Query crit = createSqlQuery(requete.toString()); crit.setLong("idAdherent", idAdherent); // on recupere les franchises des annees N et N-1 final Calendar dateAnneePrecedente = Calendar.getInstance(); final int anneePrecedente = dateAnneePrecedente.get(Calendar.YEAR) - 1; dateAnneePrecedente.clear(); dateAnneePrecedente.set(Calendar.DAY_OF_MONTH, 1); dateAnneePrecedente.set(Calendar.MONTH, 0); dateAnneePrecedente.set(Calendar.YEAR, anneePrecedente); final Calendar dateDuJour = Calendar.getInstance(); dateDuJour.clear(Calendar.MILLISECOND); dateDuJour.clear(Calendar.SECOND); dateDuJour.clear(Calendar.MINUTE); dateDuJour.clear(Calendar.HOUR_OF_DAY); crit.setCalendar("dateAnneePrecedente", dateAnneePrecedente); crit.setCalendar("dateDuJour", dateDuJour); final List<Object[]> resultSet = crit.list(); final List<ReserveProduitBancoDto> results = new ArrayList<ReserveProduitBancoDto>(); if (resultSet == null || resultSet.isEmpty()) { return null; } else { for (Object[] row : resultSet) { final ReserveProduitBancoDto reserveDto = new ReserveProduitBancoDto(); reserveDto.setReserveAnnuelle(Double.parseDouble(row[0].toString())); reserveDto.setReserveConsommee(Double.parseDouble(row[1].toString())); final Calendar dateDebutReserve = Calendar.getInstance(); dateDebutReserve.setTime((Timestamp) row[2]); reserveDto.setDateDebutReserve(dateDebutReserve); final Calendar dateFinReserve = Calendar.getInstance(); dateFinReserve.setTime((Timestamp) row[3]); reserveDto.setDateFinReserve(dateFinReserve); final Calendar dateAnniversaire = Calendar.getInstance(); dateAnniversaire.setTime((Timestamp) row[4]); reserveDto.setDateAnniversaire(dateAnniversaire); results.add(reserveDto); } return results; } }
From source file:com.square.logs.core.dao.implementations.LogDaoImplementation.java
License:Open Source License
@Override @SuppressWarnings("unchecked") public List<Long> getIdsLogsBeforeDate(Calendar date, int pagination) { final String requete = "SELECT id FROM Log WHERE date <= :date ORDER BY date ASC"; final Query query = createQuery(requete); query.setCalendar("date", date); query.setFirstResult(0);// w ww . ja va 2s .co m query.setMaxResults(pagination); return (List<Long>) query.list(); }