Examples of JPQLStatement


Examples of it.eng.qbe.statement.jpa.JPQLStatement

    statement = null;
   
    if(dataSource instanceof IHibernateDataSource) {
      statement = new HQLStatement((IHibernateDataSource)dataSource, query);
    } else if (dataSource instanceof JPADataSource) {
      statement = new JPQLStatement((JPADataSource)dataSource, query);
    } else {
      throw new RuntimeException("Impossible to create statement from a datasource of type [" + dataSource.getClass().getName() + "]");
    }
   
    return statement;
View Full Code Here

Examples of org.apache.olingo.odata2.jpa.processor.api.jpql.JPQLStatement

      } else {
        contextType = JPQLContextType.SELECT;
      }

      JPQLContext jpqlContext = JPQLContext.createBuilder(contextType, resultsView).build();
      JPQLStatement jpqlStatement = JPQLStatement.createBuilder(jpqlContext).build();
      String deltaToken = ODataJPATombstoneContext.getDeltaToken();

      Query query = null;
      if (deltaToken != null) {
        String statement = jpqlStatement.toString();
        String[] statementParts = statement.split(JPQLStatement.KEYWORD.WHERE);
        String deltaCondition = jpqlContext.getJPAEntityAlias() + ".creationDate >= {ts '" + deltaToken + "'}";
        if (statementParts.length > 1) {
          statement =
              statementParts[0] + JPQLStatement.DELIMITER.SPACE + JPQLStatement.KEYWORD.WHERE
                  + JPQLStatement.DELIMITER.SPACE + deltaCondition + JPQLStatement.DELIMITER.SPACE
                  + JPQLStatement.Operator.AND + statementParts[1];
        } else {
          statement =
              statementParts[0] + JPQLStatement.DELIMITER.SPACE + JPQLStatement.KEYWORD.WHERE
                  + JPQLStatement.DELIMITER.SPACE + deltaCondition;
        }

        query = em.createQuery(statement);
      } else {
        query = em.createQuery(jpqlStatement.toString());
      }

      return query;
    } catch (EdmException e) {
      return null;
View Full Code Here

Examples of org.apache.olingo.odata2.jpa.processor.api.jpql.JPQLStatement

      } else {
        jpqlContext = JPQLContext.createBuilder(contextType,
            uriParserResultView).build();
      }

      JPQLStatement jpqlStatement = JPQLStatement.createBuilder(jpqlContext)
          .build();
      Map<String, String> customQueryOptions = uriParserResultView.getCustomQueryOptions();
      String deltaToken = null;
      if (customQueryOptions != null) {
        deltaToken = uriParserResultView.getCustomQueryOptions().get("!deltatoken");
      }
      if (deltaToken != null) {
        ODataJPATombstoneContext.setDeltaToken(deltaToken);
      }

      Query query = null;
      List<Object> result = null;

      JPAEdmMapping mapping = (JPAEdmMapping) uriParserResultView.getTargetEntitySet().getEntityType().getMapping();
      ODataJPATombstoneEntityListener listener = null;
      if (mapping.getODataJPATombstoneEntityListener() != null) {
        listener = (ODataJPATombstoneEntityListener) mapping.getODataJPATombstoneEntityListener().newInstance();
        query = listener.getQuery(uriParserResultView, em);
      }
      if (query == null) {
        query = em.createQuery(jpqlStatement.toString());
        if (listener != null) {
          query.getResultList();
          List<Object> deltaResult =
              (List<Object>) ODataJPATombstoneContext.getDeltaResult(((EdmMapping) mapping).getInternalName());
          result = handlePaging(deltaResult, uriParserResultView);
View Full Code Here

Examples of org.apache.olingo.odata2.jpa.processor.api.jpql.JPQLStatement

    }

    JPQLContext jpqlContext = JPQLContext.createBuilder(contextType,
        resultsView).build();

    JPQLStatement jpqlStatement = JPQLStatement.createBuilder(jpqlContext)
        .build();
    Query query = null;
    try {

      query = em.createQuery(jpqlStatement.toString());
      List<?> resultList = query.getResultList();
      if (resultList != null && resultList.size() == 1) {
        return Long.valueOf(resultList.get(0).toString());
      }
    } catch (IllegalArgumentException e) {
View Full Code Here

Examples of org.apache.olingo.odata2.jpa.processor.api.jpql.JPQLStatement

    }

    JPQLContext jpqlContext = JPQLContext.createBuilder(contextType,
        resultsView).build();

    JPQLStatement jpqlStatement = JPQLStatement.createBuilder(jpqlContext)
        .build();
    Query query = null;
    try {

      query = em.createQuery(jpqlStatement.toString());
      List<?> resultList = query.getResultList();
      if (resultList != null && resultList.size() == 1) {
        return Long.valueOf(resultList.get(0).toString());
      }
    } catch (IllegalArgumentException e) {
View Full Code Here

Examples of org.apache.olingo.odata2.jpa.processor.api.jpql.JPQLStatement

        || uriParserResultView instanceof PutMergePatchUriInfo) {

      JPQLContext selectJPQLContext = JPQLContext.createBuilder(
          contextType, uriParserResultView).build();

      JPQLStatement selectJPQLStatement = JPQLStatement.createBuilder(
          selectJPQLContext).build();
      Query query = null;
      try {
        query = em.createQuery(selectJPQLStatement.toString());
        if (!query.getResultList().isEmpty()) {
          selectedObject = query.getResultList().get(0);
        }
      } catch (IllegalArgumentException e) {
        throw ODataJPARuntimeException.throwException(
View Full Code Here

Examples of org.apache.olingo.odata2.jpa.processor.api.jpql.JPQLStatement

  @Test
  public void testBuild() throws Exception {
    setUp(getJoinClauseList());
    JPQLJoinStatementBuilder jpqlJoinStatementBuilder = new JPQLJoinStatementBuilder(context);
    try {
      JPQLStatement jpqlStatement = jpqlJoinStatementBuilder.build();
      assertEquals(
          "SELECT mat FROM SOHeader soh JOIN soh.soItem soi JOIN soi.material mat WHERE soh.buyerId = 2 AND "
              +
              "soh.createdBy = 'Peter' AND soi.shId = soh.soId AND mat.id = 'abc' "
              +
              "ORDER BY mat.buyerId asc , mat.city desc",
          jpqlStatement.toString());
    } catch (ODataJPARuntimeException e) {
      fail("Should not have come here");
    }

  }
View Full Code Here

Examples of org.apache.olingo.odata2.jpa.processor.api.jpql.JPQLStatement

  public void testBuild() throws Exception {
    setUp(getJoinClauseList());
    JPQLJoinSelectSingleStatementBuilder jpqlJoinSelectsingleStatementBuilder =
        new JPQLJoinSelectSingleStatementBuilder(context);
    try {
      JPQLStatement jpqlStatement = jpqlJoinSelectsingleStatementBuilder.build();
      assertEquals(
          "SELECT gt1 FROM SOHeader soh JOIN soh.soItem soi JOIN soi.material mat WHERE soh.soId = 1 AND " +
              "soi.shId = soh.soId AND mat.id = 'abc'",
          jpqlStatement.toString());
    } catch (ODataJPARuntimeException e) {
      fail("Should not have come here");
    }

  }
View Full Code Here

Examples of org.apache.olingo.odata2.jpa.processor.api.jpql.JPQLStatement

    } else {
      jpqlContext = JPQLContext.createBuilder(contextType,
          uriParserResultView).build();
    }

    JPQLStatement jpqlStatement = JPQLStatement.createBuilder(jpqlContext)
        .build();
    Query query = null;
    try {
      query = em.createQuery(jpqlStatement.toString());
      return handlePaging(query, uriParserResultView);
    } catch (Exception e) {
      throw ODataJPARuntimeException.throwException(
          ODataJPARuntimeException.ERROR_JPQL_QUERY_CREATE, e);
View Full Code Here

Examples of org.apache.olingo.odata2.jpa.processor.api.jpql.JPQLStatement

    }

    JPQLContext jpqlContext = JPQLContext.createBuilder(contextType,
        resultsView).build();

    JPQLStatement jpqlStatement = JPQLStatement.createBuilder(jpqlContext)
        .build();
    Query query = null;
    try {

      query = em.createQuery(jpqlStatement.toString());
      List<?> resultList = query.getResultList();
      if (resultList != null && resultList.size() == 1) {
        return Long.valueOf(resultList.get(0).toString());
      }
    } catch (IllegalArgumentException e) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.