com.j256.ormlite.stmt.Where.ne()方法的使用及代码示例

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

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

Where.ne介绍

[英]Add a '<>' clause so the column must be not-equal-to the value.
[中]添加“<>”子句,使该列不能等于该值。

代码示例

代码示例来源:origin: QuickBlox/q-municate-android

public List<DialogNotification> getDialogNotificationsByDialogIdAndDate(String dialogId, long createdDate, boolean moreDate) {
  List<DialogNotification> dialogNotificationsList = new ArrayList<>();
  try {
    QueryBuilder<DialogNotification, Long> messageQueryBuilder = dao.queryBuilder();
    Where<DialogNotification, Long> where = messageQueryBuilder.where();
    where.and(where.ne(DialogNotification.Column.STATE, State.TEMP_LOCAL),
        where.ne(DialogNotification.Column.STATE, State.TEMP_LOCAL_UNREAD),
        moreDate
            ? where.gt(DialogNotification.Column.CREATED_DATE, createdDate)
            : where.lt(DialogNotification.Column.CREATED_DATE, createdDate));
    QueryBuilder<DialogOccupant, Long> dialogOccupantQueryBuilder = dialogOccupantDao
        .queryBuilder();
    QueryBuilder<Dialog, Long> dialogQueryBuilder = dialogDao.queryBuilder();
    dialogQueryBuilder.where().eq(Dialog.Column.ID, dialogId);
    dialogOccupantQueryBuilder.join(dialogQueryBuilder);
    messageQueryBuilder.join(dialogOccupantQueryBuilder);
    PreparedQuery<DialogNotification> preparedQuery = messageQueryBuilder.prepare();
    dialogNotificationsList = dao.query(preparedQuery);
  } catch (SQLException e) {
    ErrorUtils.logError(e);
  }
  return dialogNotificationsList;
}

代码示例来源:origin: QuickBlox/q-municate-android

public List<Message> getMessagesByDialogIdAndDate(String dialogId, long createdDate, boolean moreDate){
  List<Message> messagesList = new ArrayList<>();
  try {
    QueryBuilder<Message, Long> messageQueryBuilder = dao.queryBuilder();
    Where<Message, Long> where = messageQueryBuilder.where();
    where.and(where.ne(Message.Column.STATE, State.TEMP_LOCAL),
        where.ne(Message.Column.STATE, State.TEMP_LOCAL_UNREAD),
        moreDate
            ? where.gt(Message.Column.CREATED_DATE, createdDate)
            : where.lt(Message.Column.CREATED_DATE, createdDate));
    QueryBuilder<DialogOccupant, Long> dialogOccupantQueryBuilder = dialogOccupantDao.queryBuilder();
    QueryBuilder<Dialog, Long> dialogQueryBuilder = dialogDao.queryBuilder();
    dialogQueryBuilder.where().eq(Dialog.Column.ID, dialogId);
    dialogOccupantQueryBuilder.join(dialogQueryBuilder);
    messageQueryBuilder.join(dialogOccupantQueryBuilder);
    PreparedQuery<Message> preparedQuery = messageQueryBuilder.prepare();
    messagesList = dao.query(preparedQuery);
  } catch (SQLException e) {
    ErrorUtils.logError(e);
  }
  return messagesList;
}

代码示例来源:origin: annmuor/jnode

case "!=":
case "<>":
  wh.ne(args[i].toString(),  new SelectArg(args[i + 2]));
  break;
case "gt":

代码示例来源:origin: mycontroller-org/mycontroller

protected void updatePurgeCondition(Where<?, Object> where, String key, Object value,
    OPERATOR operator) throws SQLException {
  switch (operator) {
    case EQ:
      where.eq(key, value);
      break;
    case GT:
      where.gt(key, value);
      break;
    case LT:
      where.lt(key, value);
      break;
    case GE:
      where.ge(key, value);
      break;
    case LE:
      where.le(key, value);
      break;
    case NE:
      where.ne(key, value);
      break;
    default:
      where.eq(key, value);
      break;
  }
}

代码示例来源:origin: j256/ormlite-core

@Test
public void testNe() throws Exception {
  Where<Foo, String> where = new Where<Foo, String>(createTableInfo(), null, databaseType);
  int val = 112;
  where.ne(Foo.VAL_COLUMN_NAME, val);
  testOperation(where, Foo.VAL_COLUMN_NAME, "<>", val);
}

代码示例来源:origin: QuickBlox/q-municate-android

public List<DialogNotification> getDialogNotificationsByDialogIdAndDate(String dialogId, long createdDate, boolean moreDate, long limit) {
  List<DialogNotification> dialogNotificationsList = new ArrayList<>();
  try {
    QueryBuilder<DialogNotification, Long> messageQueryBuilder = dao.queryBuilder();
    Where<DialogNotification, Long> where = messageQueryBuilder.where();
    where.and(where.ne(DialogNotification.Column.STATE, State.TEMP_LOCAL),
        where.ne(DialogNotification.Column.STATE, State.TEMP_LOCAL_UNREAD),
        moreDate
            ? where.gt(DialogNotification.Column.CREATED_DATE, createdDate)
            : where.lt(DialogNotification.Column.CREATED_DATE, createdDate));
    QueryBuilder<DialogOccupant, Long> dialogOccupantQueryBuilder = dialogOccupantDao
        .queryBuilder();
    QueryBuilder<Dialog, Long> dialogQueryBuilder = dialogDao.queryBuilder();
    dialogQueryBuilder.where().eq(Dialog.Column.ID, dialogId);
    dialogOccupantQueryBuilder.join(dialogQueryBuilder);
    messageQueryBuilder
        .join(dialogOccupantQueryBuilder)
        .orderBy(DialogNotification.Column.CREATED_DATE, false)
        .limit(limit);
    PreparedQuery<DialogNotification> preparedQuery = messageQueryBuilder.prepare();
    dialogNotificationsList = dao.query(preparedQuery);
  } catch (SQLException e) {
    ErrorUtils.logError(e);
  }
  return dialogNotificationsList;
}

代码示例来源:origin: QuickBlox/q-municate-android

public List<Message> getMessagesByDialogIdAndDate(String dialogId, long createdDate, boolean moreDate, long limit){
  List<Message> messagesList = new ArrayList<>();
  try {
    QueryBuilder<Message, Long> messageQueryBuilder = dao.queryBuilder();
    Where<Message, Long> where = messageQueryBuilder.where();
    where.and(where.ne(Message.Column.STATE, State.TEMP_LOCAL),
        where.ne(Message.Column.STATE, State.TEMP_LOCAL_UNREAD),
        moreDate
            ? where.gt(Message.Column.CREATED_DATE, createdDate)
            : where.lt(Message.Column.CREATED_DATE, createdDate));
    QueryBuilder<DialogOccupant, Long> dialogOccupantQueryBuilder = dialogOccupantDao.queryBuilder();
    QueryBuilder<Dialog, Long> dialogQueryBuilder = dialogDao.queryBuilder();
    dialogQueryBuilder.where().eq(Dialog.Column.ID, dialogId);
    dialogOccupantQueryBuilder.join(dialogQueryBuilder);
    messageQueryBuilder
        .join(dialogOccupantQueryBuilder)
        .orderBy(Message.Column.CREATED_DATE, false)
        .limit(limit);
    PreparedQuery<Message> preparedQuery = messageQueryBuilder.prepare();
    messagesList = dao.query(preparedQuery);
  } catch (SQLException e) {
    ErrorUtils.logError(e);
  }
  return messagesList;
}

代码示例来源:origin: QuickBlox/q-municate-android

public List<DialogNotification> getUnreadDialogNotifications(List<Long> dialogOccupantsIdsList, int currentUserId) {
  long count = 0;
  List<DialogNotification> dialogNotificationsList = null;
  try {
    QueryBuilder<DialogNotification, Long> queryBuilder = dao.queryBuilder();
    QueryBuilder<DialogOccupant, Long> dialogOccupantQueryBuilder = dialogOccupantDao.queryBuilder();
    dialogOccupantQueryBuilder.where().ne(QMUserColumns.ID, currentUserId);
    queryBuilder.join(dialogOccupantQueryBuilder);
    Where<DialogNotification, Long> where = queryBuilder.where();
    where.and(
        where.in(DialogOccupant.Column.ID, dialogOccupantsIdsList),
        where.or(
            where.eq(DialogNotification.Column.STATE, State.DELIVERED),
            where.eq(DialogNotification.Column.STATE, State.TEMP_LOCAL_UNREAD)
        )
    );
    PreparedQuery<DialogNotification> preparedQuery = queryBuilder.prepare();
    Log.i(TAG, "query=" + preparedQuery.getStatement());
    dialogNotificationsList = dao.query(preparedQuery);
  } catch (SQLException e) {
    ErrorUtils.logError(e);
  }
  return dialogNotificationsList;
}

代码示例来源:origin: QuickBlox/q-municate-android

public List<Message> getUnreadMessages(List<Long> dialogOccupantsIdsList, int currentUserId) {
  try {
    QueryBuilder<Message, Long> queryBuilder = dao.queryBuilder();
    QueryBuilder<DialogOccupant, Long> dialogOccupantQueryBuilder = dialogOccupantDao.queryBuilder();
    dialogOccupantQueryBuilder.where().ne(QMUserColumns.ID, currentUserId);
    queryBuilder.join(dialogOccupantQueryBuilder);
    Where<Message, Long> where = queryBuilder.where();
    where.and(
        where.in(DialogOccupant.Column.ID, dialogOccupantsIdsList),
        where.or(
            where.eq(Message.Column.STATE, State.DELIVERED),
            where.eq(Message.Column.STATE, State.TEMP_LOCAL_UNREAD)
        )
    );
    PreparedQuery<Message> preparedQuery = queryBuilder.prepare();
    return dao.query(preparedQuery);
  } catch (SQLException e) {
    ErrorUtils.logError(e);
  }
  return null;
}

代码示例来源:origin: ngageoint/geopackage-android

QueryBuilder<DataColumns, TableColumnKey> qb = dao
    .queryBuilder();
qb.where().ne(DataColumns.COLUMN_CONSTRAINT_NAME,
    updatedConstraintName);
PreparedQuery<DataColumns> preparedQuery = qb.prepare();
ub.updateColumnValue(DataColumns.COLUMN_CONSTRAINT_NAME,
    updatedConstraintName);
ub.where().ne(DataColumns.COLUMN_CONSTRAINT_NAME,
    updatedConstraintName);
PreparedUpdate<DataColumns> update = ub.prepare();

代码示例来源:origin: QuickBlox/q-municate-android

public long getCountUnreadMessages(List<Long> dialogOccupantsIdsList, int currentUserId) {
  long count = 0;
  try {
    QueryBuilder<Message, Long> queryBuilder = dao.queryBuilder();
    queryBuilder.setCountOf(true);
    QueryBuilder<DialogOccupant, Long> dialogOccupantQueryBuilder = dialogOccupantDao.queryBuilder();
    dialogOccupantQueryBuilder.where().ne(QMUserColumns.ID, currentUserId);
    queryBuilder.join(dialogOccupantQueryBuilder);
    Where<Message, Long> where = queryBuilder.where();
    where.and(
        where.in(DialogOccupant.Column.ID, dialogOccupantsIdsList),
        where.or(
            where.eq(Message.Column.STATE, State.DELIVERED),
            where.eq(Message.Column.STATE, State.TEMP_LOCAL_UNREAD)
        )
    );
    PreparedQuery<Message> preparedQuery = queryBuilder.prepare();
    count = dao.countOf(preparedQuery);
  } catch (SQLException e) {
    ErrorUtils.logError(e);
  }
  return count;
}

代码示例来源:origin: QuickBlox/q-municate-android

public long getCountUnreadDialogNotifications(List<Long> dialogOccupantsIdsList, int currentUserId) {
  long count = 0;
  try {
    QueryBuilder<DialogNotification, Long> queryBuilder = dao.queryBuilder();
    queryBuilder.setCountOf(true);
    QueryBuilder<DialogOccupant, Long> dialogOccupantQueryBuilder = dialogOccupantDao.queryBuilder();
    dialogOccupantQueryBuilder.where().ne(QMUserColumns.ID, currentUserId);
    queryBuilder.join(dialogOccupantQueryBuilder);
    Where<DialogNotification, Long> where = queryBuilder.where();
    where.and(
        where.in(DialogOccupant.Column.ID, dialogOccupantsIdsList),
        where.or(
            where.eq(DialogNotification.Column.STATE, State.DELIVERED),
            where.eq(DialogNotification.Column.STATE, State.TEMP_LOCAL_UNREAD)
        )
    );
    PreparedQuery<DialogNotification> preparedQuery = queryBuilder.prepare();
    count = dao.countOf(preparedQuery);
  } catch (SQLException e) {
    ErrorUtils.logError(e);
  }
  return count;
}

代码示例来源:origin: ngageoint/geopackage-android

ub.updateColumnValue(MetadataReference.COLUMN_TABLE_NAME,
    updatedTable);
ub.where().ne(MetadataReference.COLUMN_REFERENCE_SCOPE,
    ReferenceScopeType.GEOPACKAGE.getValue());
PreparedUpdate<MetadataReference> update = ub.prepare();

代码示例来源:origin: com.j256.ormlite/ormlite-jdbc

assertEquals(foo1, results.get(0));
qb.where().ne(Foo.VAL_COLUMN_NAME, foo1.val);
results = fooDao.query(qb.prepare());
assertEquals(1, results.size());
assertEquals(foo2, results.get(0));
qb.where().ne(Foo.VAL_COLUMN_NAME, foo1.val).and().ne(Foo.VAL_COLUMN_NAME, foo2.val);
results = fooDao.query(qb.prepare());
assertEquals(0, results.size());

相关文章