Example usage for org.hibernate.transform AliasToEntityMapResultTransformer INSTANCE

List of usage examples for org.hibernate.transform AliasToEntityMapResultTransformer INSTANCE

Introduction

In this page you can find the example usage for org.hibernate.transform AliasToEntityMapResultTransformer INSTANCE.

Prototype

AliasToEntityMapResultTransformer INSTANCE

To view the source code for org.hibernate.transform AliasToEntityMapResultTransformer INSTANCE.

Click Source Link

Usage

From source file:ispyb.server.common.services.shipping.Shipping3ServiceBean.java

License:Open Source License

@Override
public List<Map<String, Object>> getShippingById(final Integer shippingId) throws Exception {

    checkCreateChangeRemoveAccess();// w ww  .  j ava2 s .  co m
    String mySQLQuery = FIND_BY_SHIPPING_ID();
    Session session = (Session) this.entityManager.getDelegate();
    SQLQuery query = session.createSQLQuery(mySQLQuery);
    query.setParameter("shippingId", shippingId);
    query.setResultTransformer(AliasToEntityMapResultTransformer.INSTANCE);
    List<Map<String, Object>> aliasToValueMapList = query.list();
    return aliasToValueMapList;
}

From source file:ispyb.server.common.services.shipping.Shipping3ServiceBean.java

License:Open Source License

@Override
public List<Map<String, Object>> getShippingByProposalId(final Integer proposalId) throws Exception {

    checkCreateChangeRemoveAccess();//from  ww w . j  a  v  a  2s  .  c  o m
    String mySQLQuery = FIND_BY_PROPOSAL_ID();
    Session session = (Session) this.entityManager.getDelegate();
    SQLQuery query = session.createSQLQuery(mySQLQuery);
    query.setParameter("proposalId", proposalId);
    query.setResultTransformer(AliasToEntityMapResultTransformer.INSTANCE);
    List<Map<String, Object>> aliasToValueMapList = query.list();
    return aliasToValueMapList;
}

From source file:ispyb.server.common.services.ws.rest.session.SessionServiceBean.java

License:Open Source License

private List<Map<String, Object>> executeSQLQuery(SQLQuery query) {
    query.setResultTransformer(AliasToEntityMapResultTransformer.INSTANCE);
    List<Map<String, Object>> aliasToValueMapList = query.list();
    return aliasToValueMapList;
}

From source file:ispyb.server.mx.services.sample.Protein3ServiceBean.java

License:Open Source License

@Override
public List<Map<String, Object>> getStatsByProposal(int proposalId) {
    String mySQLQuery = getViewTableQuery() + " where proposalId = :proposalId";
    Session session = (Session) this.entityManager.getDelegate();
    SQLQuery query = session.createSQLQuery(mySQLQuery);
    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>> getViewDataCollectionByProteinAcronym(int proposalId, String proteinAcronym) {
    String mySQLQuery = getViewTableQuery()
            + " where BLSession_proposalId = :proposalId and Protein_acronym = :proteinAcronym";
    mySQLQuery = mySQLQuery//w w  w . j a v a 2 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 ww  .j av  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("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//  ww w.j a  va 2s.co 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("Workflow_workflowId", workflowId);
    query.setParameter("proposalId", proposalId);
    query.setResultTransformer(AliasToEntityMapResultTransformer.INSTANCE);
    return executeSQLQuery(query);
}

From source file:monasca.api.infrastructure.persistence.hibernate.AlarmDefinitionSqlRepoImpl.java

License:Apache License

private static ResultTransformer getAlarmDefResultTransformer() {
    return new ResultTransformer() {
        private static final long serialVersionUID = -3052468375925339521L;

        @Override//from   www  .j  a v a2 s .  c o  m
        public Object transformTuple(final Object[] tuple, final String[] aliases) {
            for (int i = 0, length = aliases.length; i < length; i++) {
                aliases[i] = aliases[i].toUpperCase();
            }
            return AliasToEntityMapResultTransformer.INSTANCE.transformTuple(tuple, aliases);
        }

        @Override
        public List transformList(final List collection) {
            return AliasToEntityMapResultTransformer.INSTANCE.transformList(collection);
        }
    };
}

From source file:mystical.controllerDAO.AbstractDAO.java

protected List<Map<String, Object>> consultaGenerica(String consulta) {

    session = Conexao.getSessionFactory().openSession();
    tx = session.beginTransaction();/*w w w  . j a va  2  s . c  om*/
    List<Map<String, Object>> objects = null;
    try {
        System.out.println("estamos na abstract antes da query");

        SQLQuery query = session.createSQLQuery(consulta);
        query.setResultTransformer(AliasToEntityMapResultTransformer.INSTANCE);
        objects = (List<Map<String, Object>>) query.list();
        System.out.println("estamos na abstract depois da query");
        tx.commit();
    } catch (HibernateException e) {
        tx.rollback();
    } finally {

        session.close();

    }
    return objects;
}

From source file:org.cgiar.ccafs.marlo.data.dao.impl.StandardDAO.java

License:Open Source License

/**
 * This method make a query that returns a not mapped object result from the model.
 * /*  www  .  j  a va2s  .  c o m*/
 * @param sqlQuery is a string representing an HQL query.
 */
public List<Map<String, Object>> findCustomQuery(String sqlQuery) {
    Session session = null;
    Transaction tx = null;

    try {
        session = this.openSession();
        tx = this.initTransaction(session);

        session.flush();
        session.clear();
        Query query = session.createSQLQuery(sqlQuery);
        query.setResultTransformer(AliasToEntityMapResultTransformer.INSTANCE);
        List<Map<String, Object>> result = query.list();
        this.commitTransaction(tx);

        return result;
    } catch (Exception e) {
        if (tx != null) {
            this.rollBackTransaction(tx);
        }
        e.printStackTrace();
        return null;
    } finally {
        if (session.isOpen()) {
            // Flushing the changes always.
        }
    }
}