List of usage examples for org.hibernate Query setTime
@Deprecated @SuppressWarnings("unchecked") default Query<R> setTime(String name, Date val)
From source file:com.cloud.bridge.util.QueryHelper.java
License:Open Source License
public static void bindParameters(Query query, Object[] params) { int pos = 0;// w w w. ja va 2s . co m if (params != null && params.length > 0) { for (Object param : params) { if (param instanceof Byte) query.setByte(pos++, ((Byte) param).byteValue()); else if (param instanceof Short) query.setShort(pos++, ((Short) param).shortValue()); else if (param instanceof Integer) query.setInteger(pos++, ((Integer) param).intValue()); else if (param instanceof Long) query.setLong(pos++, ((Long) param).longValue()); else if (param instanceof Float) query.setFloat(pos++, ((Float) param).floatValue()); else if (param instanceof Double) query.setDouble(pos++, ((Double) param).doubleValue()); else if (param instanceof Boolean) query.setBoolean(pos++, ((Boolean) param).booleanValue()); else if (param instanceof Character) query.setCharacter(pos++, ((Character) param).charValue()); else if (param instanceof Date) query.setDate(pos++, (Date) param); else if (param instanceof Calendar) query.setCalendar(pos++, (Calendar) param); else if (param instanceof CalendarDateParam) query.setCalendarDate(pos++, ((CalendarDateParam) param).dateValue()); else if (param instanceof TimestampParam) query.setTimestamp(pos++, ((TimestampParam) param).timestampValue()); else if (param instanceof TimeParam) query.setTime(pos++, ((TimeParam) param).timeValue()); else if (param instanceof String) query.setString(pos++, (String) param); else if (param instanceof TextParam) query.setText(pos++, ((TextParam) param).textValue()); else if (param instanceof byte[]) query.setBinary(pos++, (byte[]) param); else if (param instanceof BigDecimal) query.setBigDecimal(pos++, (BigDecimal) param); else if (param instanceof BigInteger) query.setBigInteger(pos++, (BigInteger) param); else if (param instanceof Locale) query.setLocale(pos++, (Locale) param); else if (param instanceof EntityParam) query.setEntity(pos++, ((EntityParam) param).entityValue()); else if (param instanceof Serializable) query.setSerializable(pos++, (Serializable) param); else query.setEntity(pos++, param); } } }
From source file:com.glaf.jbpm.util.HibernateUtils.java
License:Apache License
public static void fillParameters(Query query, List<Object> values) { if (values == null || values.size() == 0) { return;//ww w . jav a 2 s. c o m } for (int i = 0; i < values.size(); i++) { Object object = values.get(i); int index = i; if (object != null) { if (object instanceof java.sql.Date) { java.sql.Date sqlDate = (java.sql.Date) object; query.setDate(index, sqlDate); } else if (object instanceof java.sql.Time) { java.sql.Time sqlTime = (java.sql.Time) object; query.setTime(index, sqlTime); } else if (object instanceof java.sql.Timestamp) { Timestamp datetime = (Timestamp) object; query.setTimestamp(index, datetime); } else if (object instanceof java.util.Date) { Timestamp datetime = DateUtils.toTimestamp((java.util.Date) object); query.setTimestamp(index, datetime); } else { query.setParameter(index, object); } } else { query.setParameter(index, null); } } }
From source file:com.qcadoo.model.internal.search.SearchQueryImpl.java
License:Open Source License
@Override public void addParameters(final Query query) { for (Map.Entry<String, String> parameter : strings.entrySet()) { query.setString(parameter.getKey(), parameter.getValue()); }/* w ww.j av a 2 s.c o m*/ for (Map.Entry<String, Boolean> parameter : booleans.entrySet()) { query.setBoolean(parameter.getKey(), parameter.getValue()); } for (Map.Entry<String, Byte> parameter : bytes.entrySet()) { query.setByte(parameter.getKey(), parameter.getValue()); } for (Map.Entry<String, Short> parameter : shorts.entrySet()) { query.setShort(parameter.getKey(), parameter.getValue()); } for (Map.Entry<String, Integer> parameter : integers.entrySet()) { query.setInteger(parameter.getKey(), parameter.getValue()); } for (Map.Entry<String, Long> parameter : longs.entrySet()) { query.setLong(parameter.getKey(), parameter.getValue()); } for (Map.Entry<String, Float> parameter : floats.entrySet()) { query.setFloat(parameter.getKey(), parameter.getValue()); } for (Map.Entry<String, Double> parameter : doubles.entrySet()) { query.setDouble(parameter.getKey(), parameter.getValue()); } for (Map.Entry<String, BigDecimal> parameter : bigDecimals.entrySet()) { query.setBigDecimal(parameter.getKey(), parameter.getValue()); } for (Map.Entry<String, Date> parameter : dates.entrySet()) { query.setDate(parameter.getKey(), parameter.getValue()); } for (Map.Entry<String, Date> parameter : times.entrySet()) { query.setTime(parameter.getKey(), parameter.getValue()); } for (Map.Entry<String, Date> parameter : timestamps.entrySet()) { query.setTimestamp(parameter.getKey(), parameter.getValue()); } for (Map.Entry<String, Object> parameter : parameters.entrySet()) { query.setParameter(parameter.getKey(), parameter.getValue()); } for (Map.Entry<String, Collection<? extends Object>> parametersList : parameterLists.entrySet()) { query.setParameterList(parametersList.getKey(), parametersList.getValue()); } for (Map.Entry<String, Object> parameter : entities.entrySet()) { query.setEntity(parameter.getKey(), parameter.getValue()); } }
From source file:net.mlw.vlh.adapter.hibernate3.util.setter.TimeSetter.java
License:Open Source License
/** * <ol>//from w w w . java2s. c o m * <li>If is value instance of the String, it try to parse value using * SimpleDateFormat with specified format.</li> * <li>If is value instance of the Date, it will set it directly to query . * </li> * <li>Otherwise it will set null to query for key.</li> * </ol> * * @see net.mlw.vlh.adapter.hibernate3.util.Setter#set(org.hibernate.Query, * java.lang.String, java.lang.Object) * @see #setFormat(String) */ public void set(Query query, String key, Object value) throws HibernateException, ParseException { Date date = null; if (value instanceof String) { if (LOGGER.isInfoEnabled()) { LOGGER.info("The key='" + key + "'s value is instance of a String, now is parsing to date."); } date = formatter.parse((String) value); } else if (value instanceof Date) { if (LOGGER.isInfoEnabled()) { LOGGER.info("The key='" + key + "' is instance of a Date."); } date = (Date) value; } else if (value == null) { if (LOGGER.isInfoEnabled()) { LOGGER.info("The key='" + key + "'s value is null."); } } else { if (LOGGER.isWarnEnabled()) { LOGGER.warn("The key's='" + key + "' value='" + value + "' was expected as Date or String parseable to Date."); } throw new IllegalArgumentException( "Cannot convert value of class " + value.getClass().getName() + " to time (key=" + key + ")"); } if (LOGGER.isInfoEnabled()) { LOGGER.info("The key='" + key + "' was set to the query as Time with the date='" + date + "'."); } query.setTime(key, date); }
From source file:org.jbpm.pvm.internal.query.HistoryActivityInstanceQueryImpl.java
License:Open Source License
protected void applyParameters(Query query) { if (tookLessThen != null) { query.setLong("tookLessThen", tookLessThen); }//from www . j a v a 2s . c om if (tookLongerThen != null) { query.setLong("tookLongerThen", tookLongerThen); } if (startedBefore != null) { query.setTime("startedBefore", startedBefore); } if (startedAfter != null) { query.setTime("startedAfter", startedAfter); } }
From source file:org.jbpm.pvm.internal.query.HistoryDetailQueryImpl.java
License:Open Source License
protected void applyParameters(Query query) { if (timeAfter != null) { query.setTime("timeAfter", timeAfter); }//from w w w. j a v a2 s . c o m if (timeBefore != null) { query.setTime("timeBefore", timeBefore); } }