org.eclipse.persistence.jpa.jpql.parser.WhereClause类的使用及代码示例

x33g5p2x  于2022-02-03 转载在 其他  
字(9.3k)|赞(0)|评价(0)|浏览(163)

本文整理了Java中org.eclipse.persistence.jpa.jpql.parser.WhereClause类的一些代码示例,展示了WhereClause类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WhereClause类的具体详情如下:
包路径:org.eclipse.persistence.jpa.jpql.parser.WhereClause
类名称:WhereClause

WhereClause介绍

[英]The WHERE clause of a query consists of a conditional expression used to select objects or values that satisfy the expression. The WHERE clause restricts the result of a select statement or the scope of an update or delete operation.

BNF:where_clause ::= WHERE conditional_expression
[中]查询的WHERE子句由一个条件表达式组成,用于选择满足该表达式的对象或值。WHERE子句限制select语句的结果或update或delete操作的范围。
BNF:where_clause ::= WHERE conditional_expression

代码示例

代码示例来源:origin: Impetus/Kundera

/**
 * Sets the filters from where clause.
 * 
 * @param query
 *            the query
 * @param m
 *            the m
 * @param useLuceneOrES
 *            the use lucene or es
 * @return the filters from where clause
 */
private Filter getFiltersFromWhereClause(KunderaQuery query, EntityMetadata m, Boolean useLuceneOrES)
{
  String idColumn = ((AbstractAttribute) m.getIdAttribute()).getJPAColumnName();
  WhereClause whereClause = KunderaQueryUtils.getWhereClause(query.getJpqlExpression());
  if (whereClause != null)
  {
    this.isWhereOrAggregation = true;
    if (!useLuceneOrES)
      return traverse(whereClause.getConditionalExpression(), m, idColumn);
  }
  return null;
}

代码示例来源:origin: stackoverflow.com

WhereClause whereClause = new WhereClause();

if(!(txt_billing2.getText().trim().isEmpty())) {
  whereClause.addParameter("BILLING", txt_billing2.getText().trim());
}

...

if(!(txt_umonth2.getText().trim().isEmpty())) {
  whereClause.addParameter("UMONTH ", txt_umonth2.getText().trim());
}

String sql = "SELECT * FROM airindia_sqlite" + whereClause.getWhereClause();
ps = con.prepareStatement(sql);

Map<Integer, Object> parameters = whereClause.getParameters();
for (Integer key : parameters.keySet()) {
  ps.setObject(key, parameters.get(key));
}

rs = ps.executeQuery();

代码示例来源:origin: org.eclipse.persistence/org.eclipse.persistence.jpa.jpql

/**
   * {@inheritDoc}
   */
  public JPQLQueryBNF getQueryBNF() {
    return getQueryBNF(WhereClauseBNF.ID);
  }
}

代码示例来源:origin: org.eclipse.persistence/org.eclipse.persistence.jpa.jpql

/**
   * {@inheritDoc}
   */
  @Override
  public void visit(WhereClause expression) {
    if (expression.hasConditionalExpression()) {
      conditionalExpression = true;
      expression.getConditionalExpression().accept(this);
      conditionalExpression = false;
    }
  }
}

代码示例来源:origin: com.haulmont.thirdparty/eclipselink

/**
   * {@inheritDoc}
   */
  @Override
  protected AbstractExpression buildExpression(AbstractExpression parent,
                         WordParser wordParser,
                         String word,
                         JPQLQueryBNF queryBNF,
                         AbstractExpression expression,
                         boolean tolerant) {

    expression = new WhereClause(parent);
    expression.parse(wordParser, tolerant);
    return expression;
  }
}

代码示例来源:origin: org.eclipse.persistence/org.eclipse.persistence.jpa.jpql

/**
   * {@inheritDoc}
   */
  @Override
  public void visit(WhereClauseStateObject stateObject) {

    if (stateObject.isDecorated()) {
      toText(stateObject);
    }
    else {
      WhereClause expression = stateObject.getExpression();

      // 'WHERE
      appendIdentifier((expression != null) ? expression.getActualIdentifier() : WHERE, WHERE);

      if (exactMatch && (expression != null) && expression.hasSpaceAfterIdentifier() ||
        stateObject.hasConditional()) {

        writer.append(SPACE);
      }

      // Conditional expression
      if (stateObject.hasConditional()) {
        stateObject.getConditional().accept(this);
      }
    }
  }
}

代码示例来源:origin: org.eclipse.persistence/org.eclipse.persistence.jpa.jpql

/**
   * {@inheritDoc}
   */
  @Override
  protected AbstractExpression buildExpression(AbstractExpression parent,
                         WordParser wordParser,
                         String word,
                         JPQLQueryBNF queryBNF,
                         AbstractExpression expression,
                         boolean tolerant) {

    expression = new WhereClause(parent);
    expression.parse(wordParser, tolerant);
    return expression;
  }
}

代码示例来源:origin: Impetus/Kundera

/**
 * Inits the filter.
 */
private void initFilter() {
  EntityMetadata metadata = KunderaMetadataManager.getEntityMetadata(kunderaMetadata, entityClass);
  Metamodel metaModel = kunderaMetadata.getApplicationMetadata().getMetamodel(getPersistenceUnit());
  EntityType entityType = metaModel.entity(entityClass);
  if (null == filter) {
    List<String> clauses = new ArrayList<String>();
    addDiscriminatorClause(clauses, entityType);
    return;
  }
  WhereClause whereClause = KunderaQueryUtils.getWhereClause(getJpqlExpression());
  KunderaQueryUtils.traverse(whereClause.getConditionalExpression(), metadata, kunderaMetadata, this, false);
  for (Object filterClause : filtersQueue) {
    if (!(filterClause instanceof String)) {
      onTypedParameter(((FilterClause) filterClause));
    }
  }
  addDiscriminatorClause(null, entityType);
}

代码示例来源:origin: org.eclipse.persistence/org.eclipse.persistence.jpa.jpql

/**
 * {@inheritDoc}
 */
@Override
protected void parse(WordParser wordParser, boolean tolerant) {
  // Parse 'DELETE FROM'
  deleteClause = new DeleteClause(this);
  deleteClause.parse(wordParser, tolerant);
  hasSpace = wordParser.skipLeadingWhitespace() > 0;
  // Parse 'WHERE'
  if (wordParser.startsWithIdentifier(WHERE)) {
    whereClause = new WhereClause(this);
    whereClause.parse(wordParser, tolerant);
  }
  // Now fully qualify attribute names with a virtual identification variable
  accept(new FullyQualifyPathExpressionVisitor());
}

代码示例来源:origin: com.haulmont.thirdparty/eclipselink

/**
   * {@inheritDoc}
   */
  public JPQLQueryBNF getQueryBNF() {
    return getQueryBNF(WhereClauseBNF.ID);
  }
}

代码示例来源:origin: Impetus/Kundera

@Override
protected List<Object> populateEntities(EntityMetadata m, Client client)
{
  MetamodelImpl metaModel = (MetamodelImpl) kunderaMetadata.getApplicationMetadata().getMetamodel(
      m.getPersistenceUnit());
  EntityType entity = metaModel.entity(m.getEntityClazz());
  Expression whereExpression = KunderaQueryUtils.getWhereClause(kunderaQuery.getJpqlExpression());
  QueryBuilder filter = whereExpression == null || whereExpression instanceof NullExpression ? null
      : esFilterBuilder.populateFilterBuilder(((WhereClause) whereExpression).getConditionalExpression(), m);
  return ((ESClient) client).executeQuery(filter, buildAggregation(kunderaQuery, m, filter), m,
      getKunderaQuery(),this.firstResult, this.maxResult);
}

代码示例来源:origin: com.haulmont.thirdparty/eclipselink

/**
 * {@inheritDoc}
 */
@Override
protected void parse(WordParser wordParser, boolean tolerant) {
  // Parse 'UPDATE'
  updateClause = new UpdateClause(this);
  updateClause.parse(wordParser, tolerant);
  hasSpaceAfterUpdateClause = wordParser.skipLeadingWhitespace() > 0;
  // Parse 'WHERE'
  if (wordParser.startsWithIdentifier(WHERE)) {
    whereClause = new WhereClause(this);
    whereClause.parse(wordParser, tolerant);
  }
  // Now fully qualify attribute names with a virtual identification variable
  accept(new FullyQualifyPathExpressionVisitor());
}

代码示例来源:origin: Impetus/Kundera

/**
 * Compile where.
 */
private void compileWhere()
{
  WhereClause whereClause = null;
  if (query.isSelectStatement())
  {
    whereClause = (WhereClause) query.getSelectStatement().getWhereClause();
  }
  else if (query.isUpdateStatement())
  {
    whereClause = (WhereClause) query.getUpdateStatement().getWhereClause();
  }
  if (query.isDeleteStatement())
  {
    whereClause = (WhereClause) query.getDeleteStatement().getWhereClause();
  }
  String content = whereClause.getConditionalExpression().toActualText();
  if (whereClause != null && content.length() == 0)
  {
    throw new JPQLParseException("keyword without value[WHERE]");
  }
  query.setFilter(content);
}

代码示例来源:origin: com.haulmont.thirdparty/eclipselink

/**
 * {@inheritDoc}
 */
@Override
protected void parse(WordParser wordParser, boolean tolerant) {
  // Parse 'DELETE FROM'
  deleteClause = new DeleteClause(this);
  deleteClause.parse(wordParser, tolerant);
  hasSpace = wordParser.skipLeadingWhitespace() > 0;
  // Parse 'WHERE'
  if (wordParser.startsWithIdentifier(WHERE)) {
    whereClause = new WhereClause(this);
    whereClause.parse(wordParser, tolerant);
  }
  // Now fully qualify attribute names with a virtual identification variable
  accept(new FullyQualifyPathExpressionVisitor());
}

代码示例来源:origin: Impetus/Kundera

@Override
public Map<String, Object> search(KunderaMetadata kunderaMetadata, KunderaQuery kunderaQuery,
    PersistenceDelegator persistenceDelegator, EntityMetadata m, int firstResult, int maxResults)
{
  ESQuery query = new ESQuery<>(kunderaQuery, persistenceDelegator, kunderaMetadata);
  MetamodelImpl metaModel = (MetamodelImpl) kunderaMetadata.getApplicationMetadata()
      .getMetamodel(m.getPersistenceUnit());
  Expression whereExpression = KunderaQueryUtils.getWhereClause(kunderaQuery.getJpqlExpression());
  QueryBuilder filter = whereExpression != null ? query.getEsFilterBuilder()
      .populateFilterBuilder(((WhereClause) whereExpression).getConditionalExpression(), m) : null;
  FilteredQueryBuilder queryBuilder = QueryBuilders.filteredQuery(null, filter);
  SearchResponse response = getSearchResponse(kunderaQuery, queryBuilder, filter, query, m, firstResult,
      maxResults, kunderaMetadata);
  return buildResultMap(response, kunderaQuery, m, metaModel);
}

代码示例来源:origin: org.eclipse.persistence/org.eclipse.persistence.jpa.jpql

/**
 * {@inheritDoc}
 */
@Override
protected void parse(WordParser wordParser, boolean tolerant) {
  // Parse 'UPDATE'
  updateClause = new UpdateClause(this);
  updateClause.parse(wordParser, tolerant);
  hasSpaceAfterUpdateClause = wordParser.skipLeadingWhitespace() > 0;
  // Parse 'WHERE'
  if (wordParser.startsWithIdentifier(WHERE)) {
    whereClause = new WhereClause(this);
    whereClause.parse(wordParser, tolerant);
  }
  // Now fully qualify attribute names with a virtual identification variable
  accept(new FullyQualifyPathExpressionVisitor());
}

代码示例来源:origin: Impetus/Kundera

Expression whereExp = whereClause.getConditionalExpression();

代码示例来源:origin: com.haulmont.thirdparty/eclipselink

whereClause = new WhereClause(this);
whereClause.parse(wordParser, tolerant);

代码示例来源:origin: Impetus/Kundera

Expression whereExp = whereClause.getConditionalExpression();
parseAndBuildFilters(entityType, scannerBuilder, whereExp);

代码示例来源:origin: org.eclipse.persistence/org.eclipse.persistence.jpa.jpql

whereClause = new WhereClause(this);
whereClause.parse(wordParser, tolerant);

相关文章