Java Code Examples for org.hibernate.Query#setBinary()

The following examples show how to use org.hibernate.Query#setBinary() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DBQueryUtil.java    From kardio with Apache License 2.0 5 votes vote down vote up
/**
 * Function the update the marathon json in the environment table
 * 
 * @param conn
 * @param environmentVO
 * 
 */
public static void updateWestMarathonJson(final EnvironmentVO environmentVO) {
	Session session = HibernateConfig.getSessionFactory().getCurrentSession();
	Transaction txn = session.beginTransaction();
	Query query = session.createQuery(HQLConstants.DB_QUERY_UPDATE_MARATHON_JSON);
	query.setBinary("marathonJson", environmentVO.getMarathonJson().getBytes());
	query.setTimestamp("lastUpdateTime", new java.sql.Timestamp(new Date().getTime()));
	query.setLong("environmentId", environmentVO.getEnvironmentId());
	query.executeUpdate();
	txn.commit();
}
 
Example 2
Source File: DBQueryUtil.java    From kardio with Apache License 2.0 5 votes vote down vote up
/**
 * Function the update the East marathon json in the environment table
 * 
 * @param conn
 * @param environmentVO
 * 
 */
public static void updateEastMarathonJson(final EnvironmentVO environmentVO) {
	Session session = HibernateConfig.getSessionFactory().getCurrentSession();
	Transaction txn = session.beginTransaction();
	Query query = session.createQuery(HQLConstants.DB_QUERY_UPDATE_EAST_MARATHON_JSON);
	query.setBinary("marathonJson", environmentVO.getEastMarathonJson().getBytes());
	query.setTimestamp("lastUpdateTime", new java.sql.Timestamp(new Date().getTime()));
	query.setLong("environmentId", environmentVO.getEnvironmentId());
	query.executeUpdate();
	txn.commit();
}
 
Example 3
Source File: QueryUtil.java    From ctsms with GNU Lesser General Public License v2.1 4 votes vote down vote up
public static void setQueryParameterFromCriterion(String propertyName, Query query, CriterionValueType valueType, int pos, CriterionInstantVO value) throws Exception {
	switch (valueType) {
		case BOOLEAN:
			query.setBoolean(pos, value.getBooleanValue());
			break;
		case BOOLEAN_HASH:
			query.setBinary(pos, CryptoUtil.hashForSearch(value.getBooleanValue()));
			break;
		case DATE:
			query.setDate(pos, value.getDateValue());
			break;
		case DATE_HASH:
			query.setBinary(pos, CryptoUtil.hashForSearch(value.getDateValue()));
			break;
		case TIME:
			query.setTime(pos, value.getTimeValue());
			break;
		case TIME_HASH:
			query.setBinary(pos, CryptoUtil.hashForSearch(value.getTimeValue()));
			break;
		case FLOAT:
			query.setFloat(pos, value.getFloatValue().floatValue());
			break;
		case FLOAT_HASH:
			query.setBinary(pos, CryptoUtil.hashForSearch(value.getFloatValue()));
			break;
		case LONG:
			query.setBigInteger(pos, new BigInteger(value.getLongValue().toString()));
			break;
		case LONG_HASH:
			query.setBinary(pos, CryptoUtil.hashForSearch(value.getLongValue()));
			break;
		case STRING:
			query.setString(pos, value.getStringValue());
			break;
		case STRING_HASH:
			query.setBinary(pos, CryptoUtil.hashForSearch(value.getStringValue()));
			break;
		case TIMESTAMP:
			query.setTimestamp(pos, value.getTimestampValue());
			break;
		case TIMESTAMP_HASH:
			query.setBinary(pos, CryptoUtil.hashForSearch(value.getTimestampValue()));
			break;
		case NONE:
			break;
		default:
			// datatype unimplemented
			throw new IllegalArgumentException(MessageFormat.format(CommonUtil.UNSUPPORTED_CRITERION_VALUE_TYPE, valueType.toString()));
	}
}
 
Example 4
Source File: QueryUtil.java    From ctsms with GNU Lesser General Public License v2.1 4 votes vote down vote up
public static void setQueryParameterFromString(Query query, Class propertyClass, int pos, String value) throws Exception {
	if (propertyClass.equals(String.class)) {
		query.setString(pos, value);
	} else if (propertyClass.equals(Long.class)) {
		query.setBigInteger(pos, new BigInteger(value));
	} else if (propertyClass.equals(java.lang.Long.TYPE)) {
		query.setBigInteger(pos, new BigInteger(value));
	} else if (propertyClass.equals(Integer.class)) {
		query.setInteger(pos, new Integer(value));
	} else if (propertyClass.equals(java.lang.Integer.TYPE)) {
		query.setInteger(pos, new Integer(value));
	} else if (propertyClass.equals(Boolean.class)) {
		query.setBoolean(pos, new Boolean(value));
	} else if (propertyClass.equals(java.lang.Boolean.TYPE)) {
		query.setBoolean(pos, new Boolean(value));
	} else if (propertyClass.equals(Float.class)) {
		query.setFloat(pos, CommonUtil.parseFloat(value, CoreUtil.getUserContext().getDecimalSeparator()));
	} else if (propertyClass.equals(java.lang.Float.TYPE)) {
		query.setFloat(pos, CommonUtil.parseFloat(value, CoreUtil.getUserContext().getDecimalSeparator()));
	} else if (propertyClass.equals(Double.class)) {
		query.setDouble(pos, CommonUtil.parseDouble(value, CoreUtil.getUserContext().getDecimalSeparator()));
	} else if (propertyClass.equals(java.lang.Double.TYPE)) {
		query.setDouble(pos, CommonUtil.parseDouble(value, CoreUtil.getUserContext().getDecimalSeparator()));
	} else if (propertyClass.equals(Date.class)) {
		query.setDate(pos, CommonUtil.parseDate(value, CommonUtil.getInputDatePattern(CoreUtil.getUserContext().getDateFormat())));
	} else if (propertyClass.equals(Timestamp.class)) {
		query.setTimestamp(pos, CommonUtil.dateToTimestamp(CommonUtil.parseDate(value, CommonUtil.getInputDateTimePattern(CoreUtil.getUserContext().getDateFormat()))));
	} else if (propertyClass.equals(VariablePeriod.class)) {
		query.setString(pos, VariablePeriod.fromString(value).name());
	} else if (propertyClass.equals(AuthenticationType.class)) {
		query.setString(pos, AuthenticationType.fromString(value).name());
	} else if (propertyClass.equals(Sex.class)) {
		query.setString(pos, Sex.fromString(value).name());
	} else if (propertyClass.equals(RandomizationMode.class)) {
		query.setString(pos, RandomizationMode.fromString(value).name());
	} else if (propertyClass.equals(DBModule.class)) {
		query.setString(pos, DBModule.fromString(value).name());
	} else if (propertyClass.equals(HyperlinkModule.class)) {
		query.setString(pos, HyperlinkModule.fromString(value).name());
	} else if (propertyClass.equals(JournalModule.class)) {
		query.setString(pos, JournalModule.fromString(value).name());
	} else if (propertyClass.equals(FileModule.class)) {
		query.setString(pos, FileModule.fromString(value).name());
	} else if (propertyClass.equals(Color.class)) {
		query.setString(pos, Color.fromString(value).name());
	} else if (propertyClass.equals(InputFieldType.class)) {
		query.setString(pos, InputFieldType.fromString(value).name());
	} else if (propertyClass.equals(EventImportance.class)) {
		query.setString(pos, EventImportance.fromString(value).name());
	} else if (propertyClass.equals(JobStatus.class)) {
		query.setString(pos, JobStatus.fromString(value).name());
	} else if (propertyClass.isArray() && propertyClass.getComponentType().equals(java.lang.Byte.TYPE)) { // only string hashes supported, no boolean, float, etc...
		query.setBinary(pos, CryptoUtil.hashForSearch(value));
	} else {
		// illegal type...
		throw new IllegalArgumentException(MessageFormat.format(CommonUtil.INPUT_TYPE_NOT_SUPPORTED, propertyClass.toString()));
	}
}