Example usage for org.hibernate SQLQuery setParameter

List of usage examples for org.hibernate SQLQuery setParameter

Introduction

In this page you can find the example usage for org.hibernate SQLQuery setParameter.

Prototype

@Override
    NativeQuery<T> setParameter(int position, Object val);

Source Link

Usage

From source file:ispyb.server.mx.services.ws.rest.datacollection.DataCollectionRestWsServiceBean.java

License:Open Source License

@Override
public Collection<? extends Map<String, Object>> getDataCollectionByDataCollectionGroupId(int proposalId,
        Integer dataCollectionGroupId) {
    String mySQLQuery = this.getViewTableQuery()
            + " where proposalId = :proposalId and dataCollectionGroupId = :dataCollectionGroupId  group by v_datacollection.dataCollectionId";
    Session session = (Session) this.entityManager.getDelegate();
    SQLQuery query = session.createSQLQuery(mySQLQuery);
    query.setParameter("proposalId", proposalId);
    query.setParameter("dataCollectionGroupId", dataCollectionGroupId);
    return executeSQLQuery(query);
}

From source file:ispyb.server.mx.services.ws.rest.datacollectiongroup.DataCollectionGroupRestWsServiceBean.java

License:Open Source License

@Override
public List<Map<String, Object>> getViewDataCollectionBySessionId(int proposalId, int sessionId) {
    String mySQLQuery = getViewTableQuery()
            + " where DataCollectionGroup_sessionId = :sessionId and BLSession_proposalId = :proposalId ";
    mySQLQuery = mySQLQuery/*  www  . j a  v a  2s.co m*/
            + " group by v_datacollection_summary.DataCollectionGroup_dataCollectionGroupId order by DataCollection_startTime desc ";
    Session session = (Session) this.entityManager.getDelegate();
    SQLQuery query = session.createSQLQuery(mySQLQuery);
    query.setParameter("sessionId", sessionId);
    query.setParameter("proposalId", proposalId);
    return executeSQLQuery(query);
}

From source file:ispyb.server.mx.services.ws.rest.datacollectiongroup.DataCollectionGroupRestWsServiceBean.java

License:Open Source License

@Override
public List<Map<String, Object>> getViewDataCollectionByProteinAcronym(int proposalId, String proteinAcronym) {
    String mySQLQuery = getViewTableQuery()
            + " where BLSession_proposalId = :proposalId and Protein_acronym = :proteinAcronym";
    mySQLQuery = mySQLQuery/*from w w  w .ja  v a2 s . c  o  m*/
            + " group by v_datacollection_summary.DataCollectionGroup_dataCollectionGroupId, v_datacollection_summary.DataCollectionGroup_dataCollectionGroupId";
    Session session = (Session) this.entityManager.getDelegate();
    SQLQuery query = session.createSQLQuery(mySQLQuery);
    query.setParameter("proposalId", proposalId);
    query.setParameter("proteinAcronym", proteinAcronym);
    query.setResultTransformer(AliasToEntityMapResultTransformer.INSTANCE);
    return executeSQLQuery(query);
}

From source file:ispyb.server.mx.services.ws.rest.datacollectiongroup.DataCollectionGroupRestWsServiceBean.java

License:Open Source License

@Override
public Collection<? extends Map<String, Object>> getViewDataCollectionByDataCollectionId(int proposalId,
        int dataCollectionId) {
    String mySQLQuery = getViewTableQuery()
            + " where DataCollection_dataCollectionId = :dataCollectionId and BLSession_proposalId = :proposalId ";
    mySQLQuery = mySQLQuery//from   w  w  w .  j  a  v  a 2 s  .c om
            + " group by v_datacollection_summary.DataCollectionGroup_dataCollectionGroupId, v_datacollection_summary.DataCollectionGroup_dataCollectionGroupId";
    Session session = (Session) this.entityManager.getDelegate();
    SQLQuery query = session.createSQLQuery(mySQLQuery);
    query.setParameter("dataCollectionId", dataCollectionId);
    query.setParameter("proposalId", proposalId);
    query.setResultTransformer(AliasToEntityMapResultTransformer.INSTANCE);
    return executeSQLQuery(query);
}

From source file:ispyb.server.mx.services.ws.rest.datacollectiongroup.DataCollectionGroupRestWsServiceBean.java

License:Open Source License

@Override
public List<Map<String, Object>> getViewDataCollectionByWorkflowId(Integer proposalId, Integer workflowId) {
    String mySQLQuery = getViewTableQuery()
            + " where Workflow_workflowId = :Workflow_workflowId and BLSession_proposalId = :proposalId ";
    mySQLQuery = mySQLQuery//  w  ww.  j  av a  2  s . com
            + " group by v_datacollection_summary.DataCollectionGroup_dataCollectionGroupId, v_datacollection_summary.DataCollectionGroup_dataCollectionGroupId";
    Session session = (Session) this.entityManager.getDelegate();
    SQLQuery query = session.createSQLQuery(mySQLQuery);
    query.setParameter("Workflow_workflowId", workflowId);
    query.setParameter("proposalId", proposalId);
    query.setResultTransformer(AliasToEntityMapResultTransformer.INSTANCE);
    return executeSQLQuery(query);
}

From source file:ispyb.server.mx.services.ws.rest.dewar.DewarRestWsServiceBean.java

License:Open Source License

@Override
public List<Map<String, Object>> getDewarViewBySessionId(int sessionId, int proposalId) {
    Session session = (Session) this.entityManager.getDelegate();
    SQLQuery query = session.createSQLQuery(BySessionId);
    query.setParameter("sessionId", sessionId);
    query.setParameter("proposalId", proposalId);
    return executeSQLQuery(query);
}

From source file:ispyb.server.mx.services.ws.rest.dewar.DewarRestWsServiceBean.java

License:Open Source License

public List<Map<String, Object>> getDewarViewByProposalId(int proposalId) {
    Session session = (Session) this.entityManager.getDelegate();
    SQLQuery query = session.createSQLQuery(ByProposalId);
    query.setParameter("proposalId", proposalId);
    return executeSQLQuery(query);
}

From source file:ispyb.server.mx.services.ws.rest.energyscan.EnergyScanRestWsServiceBean.java

License:Open Source License

@Override
public List<Map<String, Object>> getViewBySessionId(int proposalId, int sessionId) {

    Session session = (Session) this.entityManager.getDelegate();
    SQLQuery query = session.createSQLQuery(BySessionId);

    query.setParameter("proposalId", proposalId);
    query.setParameter("sessionId", sessionId);

    return executeSQLQuery(query);
}

From source file:ispyb.server.mx.services.ws.rest.energyscan.EnergyScanRestWsServiceBean.java

License:Open Source License

@Override
public List<Map<String, Object>> getViewById(int proposalId, int energyScanId) {
    Session session = (Session) this.entityManager.getDelegate();
    SQLQuery query = session.createSQLQuery(ById);

    query.setParameter("proposalId", proposalId);
    query.setParameter("energyScanId", energyScanId);

    return executeSQLQuery(query);
}

From source file:ispyb.server.mx.services.ws.rest.phasing.PhasingRestWsServiceBean.java

License:Open Source License

@Override
public List<Map<String, Object>> getPhasingViewByDataCollectionGroupId(int dataCollectionGroupId,
        int proposalId) {
    Session session = (Session) this.entityManager.getDelegate();
    SQLQuery query = session.createSQLQuery(ByDataCollectionGroupId);
    query.setParameter("dataCollectionGroupId", dataCollectionGroupId);
    query.setParameter("proposalId", proposalId);
    System.out.println(query.getQueryString());
    return executeSQLQuery(query);
}