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.biosaxs.services.core.analysis.Analysis3ServiceBean.java

License:Open Source License

@Override
public List<Map<String, Object>> getExperimentListByExperimentId(Integer proposalId, Integer experimentId) {
    String mySQLQuery = SQLQueryKeeper.getExperimentListByExperimentId(proposalId, experimentId);
    Session session = (Session) this.entityManager.getDelegate();
    SQLQuery query = session.createSQLQuery(mySQLQuery);
    query.setParameter("proposalId", proposalId);
    query.setParameter("experimentId", experimentId);
    query.setResultTransformer(AliasToEntityMapResultTransformer.INSTANCE);
    @SuppressWarnings("unchecked")
    List<Map<String, Object>> aliasToValueMapList = query.list();
    return aliasToValueMapList;
}

From source file:ispyb.server.biosaxs.services.core.analysis.Analysis3ServiceBean.java

License:Open Source License

@Override
public List<Map<String, Object>> getCompactAnalysisByExperimentId(int experimentId) {
    String mySQLQuery = SQLQueryKeeper.getAnalysisCompactQueryByExperimentId();
    Session session = (Session) this.entityManager.getDelegate();
    SQLQuery query = session.createSQLQuery(mySQLQuery);
    query.setParameter("experimentId", experimentId);
    query.setResultTransformer(AliasToEntityMapResultTransformer.INSTANCE);
    @SuppressWarnings("unchecked")
    List<Map<String, Object>> aliasToValueMapList = query.list();
    return aliasToValueMapList;
}

From source file:ispyb.server.biosaxs.services.core.analysis.Analysis3ServiceBean.java

License:Open Source License

@Override
public List<Map<String, Object>> getCompactAnalysisByProposalId(Integer proposalId, Integer limit) {
    StringBuilder mySQLQuery = new StringBuilder(SQLQueryKeeper.getAnalysisCompactQueryByProposalId(limit));
    Session session = (Session) this.entityManager.getDelegate();
    SQLQuery query = session.createSQLQuery(mySQLQuery.toString());
    query.setParameter("proposalId", proposalId);
    query.setResultTransformer(AliasToEntityMapResultTransformer.INSTANCE);
    @SuppressWarnings("unchecked")
    List<Map<String, Object>> aliasToValueMapList = query.list();
    return aliasToValueMapList;
}

From source file:ispyb.server.biosaxs.services.core.analysis.Analysis3ServiceBean.java

License:Open Source License

@Override
public List<Map<String, Object>> getCompactAnalysisByProposalId(Integer proposalId, Integer start,
        Integer limit) {/*from   w  w w .j  a  v a2s. co  m*/
    StringBuilder mySQLQuery = new StringBuilder(
            SQLQueryKeeper.getAnalysisCompactQueryByProposalId(start, limit));
    Session session = (Session) this.entityManager.getDelegate();
    SQLQuery query = session.createSQLQuery(mySQLQuery.toString());
    query.setParameter("proposalId", proposalId);
    query.setResultTransformer(AliasToEntityMapResultTransformer.INSTANCE);
    @SuppressWarnings("unchecked")
    List<Map<String, Object>> aliasToValueMapList = query.list();
    return aliasToValueMapList;
}

From source file:ispyb.server.biosaxs.services.core.analysis.Analysis3ServiceBean.java

License:Open Source License

@Override
public java.math.BigInteger getCountCompactAnalysisByExperimentId(Integer proposalId) {
    StringBuilder mySQLQuery = new StringBuilder(
            SQLQueryKeeper.getCountAnalysisCompactQueryByProposalId(proposalId));
    Session session = (Session) this.entityManager.getDelegate();
    SQLQuery query = session.createSQLQuery(mySQLQuery.toString());
    query.setParameter("proposalId", proposalId);
    return (java.math.BigInteger) query.uniqueResult();
}

From source file:ispyb.server.biosaxs.services.core.analysis.Analysis3ServiceBean.java

License:Open Source License

@Override
public List<Map<String, Object>> getCompactAnalysisBySubtractionId(String subtractionId) {
    StringBuilder mySQLQuery = new StringBuilder(SQLQueryKeeper.getAnalysisCompactQueryBySubtractionId());
    Session session = (Session) this.entityManager.getDelegate();
    SQLQuery query = session.createSQLQuery(mySQLQuery.toString());
    query.setParameter("subtractionId", subtractionId);
    query.setResultTransformer(AliasToEntityMapResultTransformer.INSTANCE);
    @SuppressWarnings("unchecked")
    List<Map<String, Object>> aliasToValueMapList = query.list();
    return aliasToValueMapList;
}

From source file:ispyb.server.biosaxs.services.core.analysis.Analysis3ServiceBean.java

License:Open Source License

@Override
public List<Map<String, Object>> getCompactAnalysisByMacromoleculeId(Integer proposalId,
        Integer macromoleculeId) {
    StringBuilder mySQLQuery = new StringBuilder(SQLQueryKeeper.getAnalysisCompactQueryByMacromoleculeId());
    System.out.println(mySQLQuery.toString());
    Session session = (Session) this.entityManager.getDelegate();
    SQLQuery query = session.createSQLQuery(mySQLQuery.toString());
    query.setParameter("proposalId", proposalId);
    query.setParameter("macromoleculeId", macromoleculeId);

    query.setResultTransformer(AliasToEntityMapResultTransformer.INSTANCE);
    @SuppressWarnings("unchecked")
    List<Map<String, Object>> aliasToValueMapList = query.list();
    return aliasToValueMapList;
}

From source file:ispyb.server.biosaxs.services.core.experiment.Experiment3ServiceBean.java

License:Open Source License

@Override
public List<Map<String, Object>> getExperimentDescription(Integer experimentId) {
    Session session = (Session) this.entityManager.getDelegate();
    SQLQuery query = session.createSQLQuery(GetExperimentDescriptionByExperimentId);
    query.setParameter("experimentId", experimentId);
    return executeSQLQuery(query);
}

From source file:ispyb.server.biosaxs.services.stats.Stats3ServiceBean.java

License:Open Source License

@Override
public List getSamplesBy(String start, String end) {
    Session session = (Session) this.entityManager.getDelegate();
    SQLQuery query = session.createSQLQuery(GET_SAMPLES_COUNT_BY_DATE);
    query.setParameter("START", start);
    query.setParameter("END", end);
    return query.list();
}

From source file:ispyb.server.biosaxs.services.stats.Stats3ServiceBean.java

License:Open Source License

@Override
public List getSessionsBy(String start, String end) {
    Session session = (Session) this.entityManager.getDelegate();
    SQLQuery query = session.createSQLQuery(GET_SESSIONS);
    query.setParameter("START", start);
    query.setParameter("END", end);
    return query.list();
}