Package org.hibernate

Examples of org.hibernate.SQLQuery$FetchReturn


    // creating header row from headerSQL (gets all columns in one row
    DataRow headerRow = null;
    if (headerFromSQL != null) {
      headerRow = new DataRow(null);
      SQLQuery headerQuery = session.createSQLQuery(headerFromSQL);

      // needs to be there otherwise an exception is thrown
      headerQuery.addScalar("stepCount", StandardBasicTypes.DOUBLE);
      headerQuery.addScalar("stepName", StandardBasicTypes.STRING);
      headerQuery.addScalar("stepOrder", StandardBasicTypes.DOUBLE);
      headerQuery.addScalar("intervall", StandardBasicTypes.STRING);

      @SuppressWarnings("rawtypes")
      List headerList = headerQuery.list();
      for (Object obj : headerList) {
        Object[] objArr = (Object[]) obj;
        try {
          headerRow.setName(new Converter(objArr[3]).getString() + "");
          headerRow.addValue(new Converter(new Converter(objArr[2]).getInteger()).getString() + " (" + new Converter(objArr[1]).getString()
              + ")", (new Converter(objArr[0]).getDouble()));

        } catch (Exception e) {
          headerRow.addValue(e.getMessage(), new Double(0));
        }
      }

    }

    SQLQuery query = session.createSQLQuery(natSQL);

    // needs to be there otherwise an exception is thrown
    query.addScalar("stepCount", StandardBasicTypes.DOUBLE);
    query.addScalar("stepName", StandardBasicTypes.STRING);
    query.addScalar("stepOrder", StandardBasicTypes.DOUBLE);
    query.addScalar("intervall", StandardBasicTypes.STRING);

    @SuppressWarnings("rawtypes")
    List list = query.list();

    DataTable dtbl = new DataTable("");

    // if headerRow is set then add it to the DataTable to set columns
    // needs to be removed later
View Full Code Here


    // adding time restrictions
    String natSQL = new SQLStepRequestsImprovedDiscrimination(this.timeFilterFrom, this.timeFilterTo, this.timeGrouping, this.myIDlist)
        .SQLMaxStepOrder(requestedType);

    Session session = Helper.getHibernateSession();
    SQLQuery query = session.createSQLQuery(natSQL);

    // needs to be there otherwise an exception is thrown
    query.addScalar("maxStep", StandardBasicTypes.DOUBLE);

    @SuppressWarnings("rawtypes")
    List list = query.list();

    if (list != null && list.size() > 0 && list.get(0) != null) {
      return new Converter(list.get(0)).getInteger();
    } else {
      return 0;
View Full Code Here

    // adding time restrictions
    String natSQL = new SQLStepRequestsImprovedDiscrimination(this.timeFilterFrom, this.timeFilterTo, this.timeGrouping, this.myIDlist)
        .SQLMinStepOrder(requestedType);

    Session session = Helper.getHibernateSession();
    SQLQuery query = session.createSQLQuery(natSQL);

    // needs to be there otherwise an exception is thrown
    query.addScalar("minStep", StandardBasicTypes.DOUBLE);

    @SuppressWarnings("rawtypes")
    List list = query.list();

    if (list != null && list.size() > 0 && list.get(0) != null) {
      return new Converter(list.get(0)).getInteger();
    } else {
      return 0;
View Full Code Here

    } else {
      natSQL = new ImprovedSQLProduction(this.timeFilterFrom, this.timeFilterTo, this.timeGrouping, IDlist).getSQL(stepname);
    }
    Session session = Helper.getHibernateSession();

    SQLQuery query = session.createSQLQuery(natSQL);

    // needs to be there otherwise an exception is thrown
    query.addScalar("volumes", StandardBasicTypes.INTEGER);
    query.addScalar("pages", StandardBasicTypes.INTEGER);
    query.addScalar("intervall", StandardBasicTypes.STRING);

    @SuppressWarnings("rawtypes")
    List list = query.list();

    StringBuilder title = new StringBuilder(StatisticsMode.PRODUCTION.getTitle());
     title.append(" (");
     title.append(this.cu.getTitle());
     if (stepname == null || stepname.equals("")) {
View Full Code Here

   *           
   * @return {@link Query}          
   *
   */
  protected SQLQuery createSQLQuery( String queryOrSqlQuery, Map<String, ?> values) {
    SQLQuery query = createSQLQuery(queryOrSqlQuery);
    if (values != null) {
      query.setProperties(values);
    }
    return query.addEntity(entityClass);
  }
View Full Code Here

    } else {
      query = getSession().createSQLQuery(queryOrNamedSQLQuery);
    }
   
    setQueryValues(query, values);
    SQLQuery sqlQuery = (SQLQuery)query;
   
    return sqlQuery.addEntity(entityClass);
  }
View Full Code Here

  }

  public Query createNativeQuery(String sqlString) {
    //adjustFlushMode();
    try {
      SQLQuery q = getSession().createSQLQuery( sqlString );
      return new QueryImpl( q, this );
    }
    catch (HibernateException he) {
      throwPersistenceException( he );
      return null;
View Full Code Here

  }

  public Query createNativeQuery(String sqlString, Class resultClass) {
    //adjustFlushMode();
    try {
      SQLQuery q = getSession().createSQLQuery( sqlString );
      q.addEntity( "alias1", resultClass.getName(), LockMode.READ );
      return new QueryImpl( q, this );
    }
    catch (HibernateException he) {
      throwPersistenceException( he );
      return null;
View Full Code Here

  }

  public Query createNativeQuery(String sqlString, String resultSetMapping) {
    //adjustFlushMode();
    try {
      SQLQuery q = getSession().createSQLQuery( sqlString );
      q.setResultSetMapping( resultSetMapping );
      return new QueryImpl( q, this );
    }
    catch (HibernateException he) {
      throwPersistenceException( he );
      return null;
View Full Code Here

    String recordsLeftMsg = "";
    Session session = sessionFactory.openSession();
    try {
      for (String tableName : tableNames) {
        String countSql = "select count(*) as RECORD_COUNT_ from "+tableName;
        SQLQuery sqlQuery = session.createSQLQuery(countSql);
        sqlQuery.addScalar("RECORD_COUNT_", Hibernate.LONG);
        Long recordCount = (Long) sqlQuery.uniqueResult();
        if (recordCount>0L) {
          recordsLeftMsg += tableName+":"+recordCount+", ";
        }
      }
    } finally {
View Full Code Here

TOP

Related Classes of org.hibernate.SQLQuery$FetchReturn

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.