private long modificationAfter(final long id, final MaterialInstance materialInstance) { BigInteger result = (BigInteger) getHibernateTemplate().execute((HibernateCallback) session -> { String sql = "SELECT id " + " FROM modifications " + " WHERE materialId = ? " + " AND id > ?" + " ORDER BY id" + " LIMIT 1"; SQLQuery query = session.createSQLQuery(sql); query.setLong(0, materialInstance.getId()); query.setLong(1, id); return query.uniqueResult(); }); return result == null ? id : result.longValue(); }
public static int updateNaturalOrderForPipeline(Session session, Long pipelineId, double naturalOrder) { String sql = "UPDATE pipelines SET naturalOrder = :naturalOrder WHERE id = :pipelineId"; SQLQuery query = session.createSQLQuery(sql); query.setLong("pipelineId", pipelineId); query.setDouble("naturalOrder", naturalOrder); return query.executeUpdate(); }
private Long findLastBuiltModificationId(final Pipeline pipeline, final MaterialInstance materialInstance) { BigInteger result = (BigInteger) getHibernateTemplate().execute((HibernateCallback) session -> { String sql = "SELECT fromRevisionId " + " FROM pipelineMaterialRevisions pmr " + " INNER JOIN pipelines p on p.id = pmr.pipelineId " + " WHERE materialId = ? " + " AND p.name = ? " + " AND pipelineId < ? " + " ORDER BY pmr.id DESC" + " LIMIT 1"; SQLQuery query = session.createSQLQuery(sql); query.setLong(0, materialInstance.getId()); query.setString(1, pipeline.getName()); query.setLong(2, pipeline.getId()); return query.uniqueResult(); }); return result == null ? null : result.longValue(); }
private List<Object[]> retrieveTimeline(Session session, PipelineTimeline pipelineTimeline) { SQLQuery query = session.createSQLQuery(queryExtensions.retrievePipelineTimeline()); query.setLong(0, pipelineTimeline.maximumId()); List<Object[]> matches = loadTimeline(query); sortTimeLineByPidAndPmrId(matches); return matches; }
query.setLong(counter, id); counter++;
query.setLong(counter, id); counter++;
String sqlQueryString = "SELECT * FROM my_classes_table WITH (nolock) WHERE columnName = :columnValue"; SQLQuery sqlQuery= session.createSQLQuery(sqlQueryString).addEntity(MyClass.class); sqlQuery.setLong("columnValue", value); List<MyClass> out = sqlQuery.list();
@SuppressWarnings( "unchecked" ) public List<Employee> findByDepartment(long departmentId){ SQLQuery query = session.createSQLQuery("SELECT {emp.*} " + " FROM employee emp " + +"WHERE emp.department_id = :departement_id"); query.setLong("department_id", departmentId); query.addEntity("emp", Employee.class); return (List<Employee>) = query.list(); }
private void updateCollectionCount(Session session, Long collectionSequenceId){ //todo try to rewrite as hql BigInteger collectionCount = (BigInteger)session.createSQLQuery(selectCollectionCountSQL).setLong("sequenceId", collectionSequenceId).uniqueResult(); session.createQuery("update CollectionSequence set collectionCount=:count where id=:sequenceId") .setInteger("count", collectionCount.intValue()) .setLong("sequenceId", collectionSequenceId) .executeUpdate(); } }
query.setLong("pdate", timestamp); List<String> allThesaurusId = query.list();
session = getSessionFactory().openSession(); String query0 = "select LOCATION from SAM_MEDIA_T where MEDIAID = :id"; mediaLocation = (String) session.createSQLQuery(query0).setLong("id", mediaId).uniqueResult(); log.debug("****mediaLocation=" + mediaLocation); session.createSQLQuery(query).setLong("id", mediaId).executeUpdate(); } catch (HibernateException e) { log.warn(e.getMessage());