com.avaje.ebean.Query.setParameter()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(3.0k)|赞(0)|评价(0)|浏览(192)

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

Query.setParameter介绍

[英]Set an ordered bind parameter according to its position. Note that the position starts at 1 to be consistent with JDBC PreparedStatement. You need to set a parameter value for each ? you have in the query.

// a query with a positioned parameter 
String oql = "where status = ? order by id desc"; 
Query<Order> query = Ebean.createQuery(Order.class, oql); 
// bind the parameter 
query.setParameter(1, OrderStatus.NEW); 
List<Order> list = query.findList();

[中]根据其位置设置有序绑定参数。注意,这个位置从1开始,与JDBC PreparedStatement一致。您需要为每个设置一个参数值吗?您在查询中有一个

// a query with a positioned parameter 
String oql = "where status = ? order by id desc"; 
Query<Order> query = Ebean.createQuery(Order.class, oql); 
// bind the parameter 
query.setParameter(1, OrderStatus.NEW); 
List<Order> list = query.findList();

代码示例

代码示例来源:origin: org.actframework/act-ebean-java7

@Override
public EbeanQuery<MODEL_TYPE> setParameter(int position, Object value) {
  q.setParameter(position, value);
  qReadOnly.setParameter(position, value);
  return this;
}

代码示例来源:origin: org.actframework/act-ebean-java7

@Override
public EbeanQuery<MODEL_TYPE> setParameter(String name, Object value) {
  q.setParameter(name, value);
  qReadOnly.setParameter(name, value);
  return this;
}

代码示例来源:origin: org.avaje/ebean

private void bindWhereParendId(Query<?> q, Object parentId) {
  if (exportedProperties.length == 1) {
    q.setParameter(1, parentId);
    
  } else {
    int pos = 1;
    for (int i = 0; i < exportedProperties.length; i++) {
      Object embVal = exportedProperties[i].getValue(parentId);
      q.setParameter(pos++, embVal);
    }
  }
}

代码示例来源:origin: org.avaje/ebean

private int bindWhereParendId(int pos, Query<?> q, Object parentId) {
  if (exportedProperties.length == 1) {
    q.setParameter(pos++, parentId);
    
  } else {
    
    for (int i = 0; i < exportedProperties.length; i++) {
      Object embVal = exportedProperties[i].getValue(parentId);
      q.setParameter(pos++, embVal);
    }
  }
  return pos;
}

代码示例来源:origin: org.avaje.ebeanorm/avaje-ebeanorm-server

private int bindWhereParendId(int pos, Query<?> q, Object parentId) {
  if (exportedProperties.length == 1) {
    q.setParameter(pos++, parentId);
    
  } else {
    
    for (int i = 0; i < exportedProperties.length; i++) {
      Object embVal = exportedProperties[i].getValue(parentId);
      q.setParameter(pos++, embVal);
    }
  }
  return pos;
}

代码示例来源:origin: org.avaje.ebeanorm/avaje-ebeanorm-server

private void bindWhereParendId(Query<?> q, Object parentId) {
  if (exportedProperties.length == 1) {
    q.setParameter(1, parentId);
    
  } else {
    int pos = 1;
    for (int i = 0; i < exportedProperties.length; i++) {
      Object embVal = exportedProperties[i].getValue(parentId);
      q.setParameter(pos++, embVal);
    }
  }
}

代码示例来源:origin: com.typesafe.play/play-java-ebean

/**
 * Sets an ordered bind parameter according to its position.
 */
public Query<T> setParameter(int position, Object value) {
  return query().setParameter(position, value);
}

代码示例来源:origin: com.typesafe.play/play-java-ebean

/**
 * Sets a named bind parameter.
 */
public Query<T> setParameter(String name, Object value) {
  return query().setParameter(name, value);
}

相关文章