List of usage examples for org.hibernate SQLQuery setSerializable
@Deprecated @SuppressWarnings("unchecked") default Query<R> setSerializable(int position, Serializable val)
From source file:ch.systemsx.cisd.openbis.generic.server.dataaccess.db.AbstractDAO.java
License:Apache License
/** * Executes given <var>sql</var>. * <p>/*w w w. ja v a 2s. com*/ * Should be an <code>INSERT</code> or <code>UPDATE</code> statement. * </p> */ protected final void executeUpdate(final String sql, final Serializable... parameters) { getHibernateTemplate().execute(new HibernateCallback() { // // HibernateCallback // public final Object doInHibernate(final Session session) throws HibernateException, SQLException { final SQLQuery sqlQuery = session.createSQLQuery(sql); for (int i = 0; i < parameters.length; i++) { Serializable parameter = parameters[i]; if (parameter instanceof Long) { sqlQuery.setLong(i, (Long) parameter); } else if (parameter instanceof Integer) { sqlQuery.setInteger(i, (Integer) parameter); } else if (parameter instanceof Character) { sqlQuery.setCharacter(i, (Character) parameter); } else if (parameter instanceof Date) { sqlQuery.setDate(i, (Date) parameter); } else { sqlQuery.setSerializable(i, parameter); } } sqlQuery.executeUpdate(); return null; } }); }