| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 
 |  
			// partie criterions hibernate simples
			c = c.add(Restrictions.ge("capacite", criteresAppareil.getPontCapacite()));
			...
			// partie criterion sql
		if ((criteresAppareil.getEtatReparation() != null) || (criteresAppareil.getDateControleDebut() != null) || (criteresAppareil.getDateControleFin() != null))
		{
			List<Object> values = new ArrayList<Object>();
			List<Type> types = new ArrayList<Type>();
			String sql = 
				"(" +
				"	select count(*) from CMT_T_CTRLAPPAREIL c " +
				"	where c.CTL_C_ID = " + 
				"	( " +
				"		select l.CTL_C_ID " + 
				"		from (select * from CMT_T_CTRLAPPAREIL ORDER BY CTL_D_DATE DESC) l " +
				"		where 1=1 " +
				"		  and l.CTA_APR_C_ID = {id} " + 
				"		  and ROWNUM = 1 " + 
				"	) ";
				if (criteresAppareil.getDateControleDebut() != null)
				{
					sql += "	  and c.CTL_D_DATE >= ? ";
					values.add(criteresAppareil.getDateControleDebut());
					types.add(Hibernate.DATE);
				}
				if (criteresAppareil.getDateControleFin() != null)
				{
					sql += "	  and c.CTL_D_DATE <= ? ";
					values.add(criteresAppareil.getDateControleFin());
					types.add(Hibernate.DATE);
				}
				if (criteresAppareil.getEtatReparation() != null)
				{
					sql += "	  and (select e.libelle_courte from CMT_T_REPARATION r, CMT_T_COD_ETATREPARATION e where r.REP_CER_C_ID = e.COD_C_ID and r.REP_C_ID = c.CTL_REP_C_ID) = ? ";
					values.add(criteresAppareil.getEtatReparation().toString());
					types.add(Hibernate.STRING);
				}
				sql += ") > 0";
			c = c.add(Expression.sqlRestriction(sql, values.toArray(), types.toArray(new Type[types.size()])));
		} | 
Partager