org.greenrobot.greendao.query.QueryBuilder.orderRaw()方法的使用及代码示例

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

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

QueryBuilder.orderRaw介绍

[英]Adds the given raw SQL string to the ORDER BY section. Do not use this for standard properties: orderAsc and orderDesc are preferred.
[中]将给定的原始SQL字符串添加到ORDER BY节。不要将其用于标准属性:orderAsc和orderDesc是首选。

代码示例

代码示例来源:origin: greenrobot/greenDAO

/** Internal query to resolve the "toManyTargetEntityList" to-many relationship of ToManyEntity. */
public List<ToManyTargetEntity> _queryToManyEntity_ToManyTargetEntityList(Long toManyId) {
  synchronized (this) {
    if (toManyEntity_ToManyTargetEntityListQuery == null) {
      QueryBuilder<ToManyTargetEntity> queryBuilder = queryBuilder();
      queryBuilder.where(Properties.ToManyId.eq(null));
      queryBuilder.orderRaw("T.'_id' ASC");
      toManyEntity_ToManyTargetEntityListQuery = queryBuilder.build();
    }
  }
  Query<ToManyTargetEntity> query = toManyEntity_ToManyTargetEntityListQuery.forCurrentThread();
  query.setParameter(0, toManyId);
  return query.list();
}

代码示例来源:origin: greenrobot/greenDAO

/** Internal query to resolve the "toManyByJoinProperty" to-many relationship of ToManyEntity. */
public List<ToManyTargetEntity> _queryToManyEntity_ToManyByJoinProperty(String targetJoinProperty) {
  synchronized (this) {
    if (toManyEntity_ToManyByJoinPropertyQuery == null) {
      QueryBuilder<ToManyTargetEntity> queryBuilder = queryBuilder();
      queryBuilder.where(Properties.TargetJoinProperty.eq(null));
      queryBuilder.orderRaw("T.'_id' ASC");
      toManyEntity_ToManyByJoinPropertyQuery = queryBuilder.build();
    }
  }
  Query<ToManyTargetEntity> query = toManyEntity_ToManyByJoinPropertyQuery.forCurrentThread();
  query.setParameter(0, targetJoinProperty);
  return query.list();
}

代码示例来源:origin: greenrobot/greenDAO

/** Internal query to resolve the "toManyDescList" to-many relationship of ToManyEntity. */
public List<ToManyTargetEntity> _queryToManyEntity_ToManyDescList(Long toManyIdDesc) {
  synchronized (this) {
    if (toManyEntity_ToManyDescListQuery == null) {
      QueryBuilder<ToManyTargetEntity> queryBuilder = queryBuilder();
      queryBuilder.where(Properties.ToManyIdDesc.eq(null));
      queryBuilder.orderRaw("T.'_id' DESC");
      toManyEntity_ToManyDescListQuery = queryBuilder.build();
    }
  }
  Query<ToManyTargetEntity> query = toManyEntity_ToManyDescListQuery.forCurrentThread();
  query.setParameter(0, toManyIdDesc);
  return query.list();
}

代码示例来源:origin: greenrobot/greenDAO

public void testOrderRaw() {
  ArrayList<TestEntity> inserted = insert(2);
  List<TestEntity> result = dao.queryBuilder().orderRaw(Properties.SimpleInteger.columnName + " ASC").list();
  assertEquals(2, result.size());
  assertEquals(inserted.get(0).getId(), result.get(0).getId());
  result = dao.queryBuilder().orderRaw(Properties.SimpleInteger.columnName + " DESC").list();
  assertEquals(2, result.size());
  assertEquals(inserted.get(1).getId(), result.get(0).getId());
}

代码示例来源:origin: greenrobot/greenDAO

/** Internal query to resolve the "toManyJoinTwo" to-many relationship of ToManyEntity. */
public List<ToManyTargetEntity> _queryToManyEntity_ToManyJoinTwo(Long toManyId, String targetJoinProperty) {
  synchronized (this) {
    if (toManyEntity_ToManyJoinTwoQuery == null) {
      QueryBuilder<ToManyTargetEntity> queryBuilder = queryBuilder();
      queryBuilder.where(Properties.ToManyId.eq(null));
      queryBuilder.where(Properties.TargetJoinProperty.eq(null));
      queryBuilder.orderRaw("T.'TARGET_JOIN_PROPERTY' DESC,T.'_id' DESC");
      toManyEntity_ToManyJoinTwoQuery = queryBuilder.build();
    }
  }
  Query<ToManyTargetEntity> query = toManyEntity_ToManyJoinTwoQuery.forCurrentThread();
  query.setParameter(0, toManyId);
  query.setParameter(1, targetJoinProperty);
  return query.list();
}

代码示例来源:origin: chat-sdk/chat-sdk-android

/** Internal query to resolve the "messages" to-many relationship of Thread. */
public List<Message> _queryThread_Messages(Long threadId) {
  synchronized (this) {
    if (thread_MessagesQuery == null) {
      QueryBuilder<Message> queryBuilder = queryBuilder();
      queryBuilder.where(Properties.ThreadId.eq(null));
      queryBuilder.orderRaw("T.'DATE' ASC");
      thread_MessagesQuery = queryBuilder.build();
    }
  }
  Query<Message> query = thread_MessagesQuery.forCurrentThread();
  query.setParameter(0, threadId);
  return query.list();
}

相关文章