Example usage for org.hibernate Query getQueryString

List of usage examples for org.hibernate Query getQueryString

Introduction

In this page you can find the example usage for org.hibernate Query getQueryString.

Prototype

String getQueryString();

Source Link

Document

Get the query string.

Usage

From source file:org.bonitasoft.engine.persistence.QueryBuilderFactory.java

License:Open Source License

public QueryBuilder createQueryBuilderFor(Query query, Class<? extends PersistentObject> entityType,
        OrderByBuilder orderByBuilder, Map<String, String> classAliasMappings,
        Map<String, Class<? extends PersistentObject>> interfaceToClassMapping, char likeEscapeCharacter) {
    if (query instanceof SQLQuery) {
        return new SQLQueryBuilder(query.getQueryString(), vendor, entityType, orderByBuilder,
                classAliasMappings, interfaceToClassMapping, likeEscapeCharacter);
    } else {/* w w  w . j  a  va  2 s . c  om*/
        return new HQLQueryBuilder(query.getQueryString(), orderByBuilder, classAliasMappings,
                interfaceToClassMapping, likeEscapeCharacter);
    }
}

From source file:org.bonitasoft.engine.persistence.SQLQueryBuilder.java

License:Open Source License

@Override
public void setTenantId(Query query, long tenantId) {
    if (query.getQueryString().contains(":tenantId")) {
        query.setParameter("tenantId", tenantId);
    }/*from w  w w.  j  a v a2 s .co  m*/
}

From source file:org.bonitasoft.engine.test.persistence.repository.FlowNodeInstanceRepository.java

License:Open Source License

@SuppressWarnings("unchecked")
public List<SHumanTaskInstance> searchSHumanTaskInstanceAssignedAndPendingByRootProcessFor(
        final long rootProcessDefinitionId, final long userId) {
    getSessionWithTenantFilter();/*from  w ww .j a  va  2 s .  co  m*/
    Query namedQuery = getNamedQuery("searchSHumanTaskInstanceAssignedAndPendingByRootProcessFor");
    namedQuery = getSession().createQuery(namedQuery.getQueryString() + " ORDER BY a.name");
    namedQuery.setParameter("userId", userId);
    namedQuery.setParameter("rootProcessDefinitionId", rootProcessDefinitionId);
    return namedQuery.list();
}

From source file:org.bonitasoft.engine.test.persistence.repository.FlowNodeInstanceRepository.java

License:Open Source License

@SuppressWarnings("unchecked")
public List<SHumanTaskInstance> searchSHumanTaskInstanceAssignedAndPendingByRootProcess(
        final long rootProcessDefinitionId) {
    getSessionWithTenantFilter();//  w w w .j a  va  2 s. co m
    Query namedQuery = getNamedQuery("searchSHumanTaskInstanceAssignedAndPendingByRootProcess");
    namedQuery = getSession().createQuery(namedQuery.getQueryString() + " ORDER BY a.name");
    namedQuery.setParameter("rootProcessDefinitionId", rootProcessDefinitionId);
    return namedQuery.list();
}

From source file:org.bonitasoft.engine.test.persistence.repository.ProcessDeploymentInfoRepository.java

License:Open Source License

@SuppressWarnings("unchecked")
public List<SProcessDefinitionDeployInfo> searchProcessDeploymentInfosWithAssignedOrPendingHumanTasks() {
    getSession().enableFilter("tenantFilter").setParameter("tenantId",
            PersistentObjectBuilder.DEFAULT_TENANT_ID);
    Query namedQuery = getNamedQuery("searchSProcessDefinitionDeployInfoWithAssignedOrPendingHumanTasks");
    namedQuery = getSession().createQuery(namedQuery.getQueryString() + " ORDER BY process_definition.id");
    return namedQuery.list();
}

From source file:org.bonitasoft.engine.test.persistence.repository.ProcessInstanceRepository.java

License:Open Source License

public long getNumberOfSProcessInstanceFailedForProcessDefinition(final long processDefinitionId) {
    getSession().enableFilter("tenantFilter").setParameter("tenantId",
            PersistentObjectBuilder.DEFAULT_TENANT_ID);
    Query namedQuery = getNamedQuery("getNumberOfSProcessInstanceFailed");
    namedQuery = getSession()//w  w w .  j  av  a 2 s.c  o  m
            .createQuery(namedQuery.getQueryString() + " AND p.processDefinitionId = " + processDefinitionId);
    return ((Number) namedQuery.uniqueResult()).longValue();
}

From source file:org.bonitasoft.engine.test.persistence.repository.ProcessInstanceRepository.java

License:Open Source License

@SuppressWarnings("unchecked")
public List<SProcessInstance> searchSProcessInstanceFailedForProcessDefinition(final long processDefinitionId) {
    getSession().enableFilter("tenantFilter").setParameter("tenantId",
            PersistentObjectBuilder.DEFAULT_TENANT_ID);
    Query namedQuery = getNamedQuery("searchSProcessInstanceFailed");
    namedQuery = getSession()/* w w w  . j  a v a2  s  .  com*/
            .createQuery(namedQuery.getQueryString() + " AND p.processDefinitionId = " + processDefinitionId);
    return namedQuery.list();
}

From source file:org.bonitasoft.engine.test.persistence.repository.ProcessInstanceRepository.java

License:Open Source License

public long getNumberOfTimerEventTriggerInstances(final long processInstanceId, final String jobTriggerName) {
    getSession().enableFilter("tenantFilter").setParameter("tenantId",
            PersistentObjectBuilder.DEFAULT_TENANT_ID);
    Query namedQuery = getNamedQuery("getNumberOfSTimerEventTriggerInstanceByProcessInstance");
    if (jobTriggerName != null) {
        namedQuery = getSession()//from   www  .  j a  v  a2  s  . c  om
                .createQuery(namedQuery.getQueryString() + " AND e.name = '" + jobTriggerName + "'");
    }
    namedQuery.setParameter("processInstanceId", processInstanceId);
    return ((Number) namedQuery.uniqueResult()).longValue();
}

From source file:org.bonitasoft.engine.test.persistence.repository.ProcessInstanceRepository.java

License:Open Source License

@SuppressWarnings("unchecked")
public List<SEventTriggerInstance> searchTimerEventTriggerInstances(final long processInstanceId,
        final String jobTriggerName) {
    getSession().enableFilter("tenantFilter").setParameter("tenantId",
            PersistentObjectBuilder.DEFAULT_TENANT_ID);
    Query namedQuery = getNamedQuery("searchSTimerEventTriggerInstanceByProcessInstance");
    if (jobTriggerName != null) {
        namedQuery = getSession()//from w ww . j  a v a2 s .c o  m
                .createQuery(namedQuery.getQueryString() + " AND e.name = '" + jobTriggerName + "'");
    }
    namedQuery.setParameter("processInstanceId", processInstanceId);
    return namedQuery.list();
}

From source file:org.brushingbits.jnap.persistence.hibernate.Dao.java

License:Apache License

/**
 * //from   w ww  .  java2 s. c o  m
 * @param query
 * @return
 */
protected Integer count(Query query) {
    if (!query.getQueryString().toLowerCase().startsWith("select count(")) {
        throw new QuerySyntaxException("The count query must start with a 'select count clause'",
                query.getQueryString());
    }
    Number quantity = (Number) query.uniqueResult();
    return quantity == null ? 0 : quantity.intValue();
}