本文整理汇总了Java中com.litesuits.orm.db.assit.QueryBuilder类的典型用法代码示例。如果您正苦于以下问题:Java QueryBuilder类的具体用法?Java QueryBuilder怎么用?Java QueryBuilder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
QueryBuilder类属于com.litesuits.orm.db.assit包,在下文中一共展示了QueryBuilder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: create
import com.litesuits.orm.db.assit.QueryBuilder; //导入依赖的package包/类
@Override
public Observable<List<Folder>> create(final List<Folder> folders) {
return Observable.create(new Observable.OnSubscribe<List<Folder>>() {
@Override
public void call(Subscriber<? super List<Folder>> subscriber) {
Date now = new Date();
for (Folder folder : folders) {
folder.setCreatedAt(now);
}
long result = mLiteOrm.save(folders);
if (result > 0) {
List<Folder> allNewFolders = mLiteOrm.query(
QueryBuilder.create(Folder.class).appendOrderAscBy(Folder.COLUMN_NAME)
);
subscriber.onNext(allNewFolders);
} else {
subscriber.onError(new Exception("Create folders failed"));
}
subscriber.onCompleted();
}
});
}
示例2: testQueryAnyUwant
import com.litesuits.orm.db.assit.QueryBuilder; //导入依赖的package包/类
private void testQueryAnyUwant() {
long nums = liteOrm.queryCount(Address.class);
OrmLog.i(this, "Address All Count : " + nums);
QueryBuilder<Address> qb = new QueryBuilder<Address>(Address.class)
.columns(new String[]{Address.COL_ADDRESS})
.appendOrderAscBy(Address.COL_ADDRESS)
.appendOrderDescBy(Address.COL_ID)
.distinct(true)
.where(Address.COL_ADDRESS + "=?", new String[]{"香港路"});
nums = liteOrm.queryCount(qb);
OrmLog.i(this, "Address All Count : " + nums);
List<Address> addrList = liteOrm.query(qb);
for (Address uu : addrList) {
OrmLog.i(this, "Query Address: " + uu);
}
}
示例3: loadDataFromCache
import com.litesuits.orm.db.assit.QueryBuilder; //导入依赖的package包/类
void loadDataFromCache() {
if (items.size() == 0) {
items.addAll(Stores.db.query(
QueryBuilder.create(Feed.class)
.whereEquals(Feed.CATEGORY, category)
.appendOrderDescBy(Feed.PUBLISHED_AT)
.distinct(true)
.limit(0, 20)
)
);
adapter.notifyDataSetChanged();
}
}
示例4: setSongAsFavorite
import com.litesuits.orm.db.assit.QueryBuilder; //导入依赖的package包/类
@Override
public Observable<Song> setSongAsFavorite(final Song song, final boolean isFavorite) {
return Observable.create(new Observable.OnSubscribe<Song>() {
@Override
public void call(Subscriber<? super Song> subscriber) {
List<PlayList> playLists = mLiteOrm.query(
QueryBuilder.create(PlayList.class).whereEquals(PlayList.COLUMN_FAVORITE, String.valueOf(true))
);
if (playLists.isEmpty()) {
PlayList defaultFavorite = DBUtils.generateFavoritePlayList(mContext);
playLists.add(defaultFavorite);
}
PlayList favorite = playLists.get(0);
song.setFavorite(isFavorite);
favorite.setUpdatedAt(new Date());
if (isFavorite) {
// Insert song to the beginning of the list
favorite.addSong(song, 0);
} else {
favorite.removeSong(song);
}
mLiteOrm.insert(song, ConflictAlgorithm.Replace);
long result = mLiteOrm.insert(favorite, ConflictAlgorithm.Replace);
if (result > 0) {
subscriber.onNext(song);
} else {
if (isFavorite) {
subscriber.onError(new Exception("Set song as favorite failed"));
} else {
subscriber.onError(new Exception("Set song as unfavorite failed"));
}
}
subscriber.onCompleted();
}
});
}
示例5: onCreate
import com.litesuits.orm.db.assit.QueryBuilder; //导入依赖的package包/类
@Override protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ButterKnife.bind(this);
mMeizhiList = new ArrayList<>();
QueryBuilder query = new QueryBuilder(Meizhi.class);
query.appendOrderDescBy("publishedAt");
query.limit(0, 10);
mMeizhiList.addAll(App.sDb.query(query));
setupRecyclerView();
setupUmeng();
AlarmManagers.register(this);
}
示例6: queryAllDesc
import com.litesuits.orm.db.assit.QueryBuilder; //导入依赖的package包/类
/**
* 查询所有并按照指定列的值降序排列
*/
public <T> Observable<ArrayList<T>> queryAllDesc(final Class<T> cls, final String column) {
return Observable.defer(new Func0<Observable<ArrayList<T>>>() {
@Override
public Observable<ArrayList<T>> call() {
return Observable.just(liteOrm.query(new QueryBuilder<>(cls).appendOrderDescBy(column)));
}
}).subscribeOn(Schedulers.io());
}
示例7: querySpecificColumnsAndDistinct
import com.litesuits.orm.db.assit.QueryBuilder; //导入依赖的package包/类
/**
* 查询 指定字段 的值并去除重复
*
* @param cls 要查询的对象类型
* @param columns 字段名称
* @return 查询结果集合
*/
public <T> Observable<ArrayList<T>> querySpecificColumnsAndDistinct(final Class<T> cls, final String[] columns) {
return Observable.defer(new Func0<Observable<ArrayList<T>>>() {
@Override
public Observable<ArrayList<T>> call() {
return Observable.just(liteOrm.query(new QueryBuilder<>(cls).columns(columns).distinct(true)));
}
}).subscribeOn(Schedulers.io());
}
示例8: queryByWhere
import com.litesuits.orm.db.assit.QueryBuilder; //导入依赖的package包/类
/**
* 查询 某字段 等于 value 的值
*
* @param cls 要查询的对象类型
* @param where 字段名称
* @param value 字段的值
* @return 查询结果集合
*/
public <T> Observable<ArrayList<T>> queryByWhere(final Class<T> cls, final String where, final String[] value) {
return Observable.defer(new Func0<Observable<ArrayList<T>>>() {
@Override
public Observable<ArrayList<T>> call() {
return Observable.just(liteOrm.query(new QueryBuilder<>(cls).where(where + "=?", value)));
}
}).subscribeOn(Schedulers.io());
}
示例9: queryByWhereAsc
import com.litesuits.orm.db.assit.QueryBuilder; //导入依赖的package包/类
/**
* 查询 某字段 等于 value 的值并按照指定列的值升序排列
*/
public <T> Observable<ArrayList<T>> queryByWhereAsc(final Class<T> cls, final String where, final String[] value, final String column) {
return Observable.defer(new Func0<Observable<ArrayList<T>>>() {
@Override
public Observable<ArrayList<T>> call() {
return Observable.just(liteOrm.query(new QueryBuilder<>(cls).where(where + "=?", value).appendOrderAscBy(column)));
}
}).subscribeOn(Schedulers.io());
}
示例10: queryByLike
import com.litesuits.orm.db.assit.QueryBuilder; //导入依赖的package包/类
public <T> Observable<ArrayList<T>> queryByLike(final Class<T> cls, final String where, final String[] value) {
return Observable.defer(new Func0<Observable<ArrayList<T>>>() {
@Override
public Observable<ArrayList<T>> call() {
return Observable.just(liteOrm.query(new QueryBuilder<>(cls).where(where + " LIKE ?", value)));
}
}).subscribeOn(Schedulers.io());
}
示例11: queryByWhereLength
import com.litesuits.orm.db.assit.QueryBuilder; //导入依赖的package包/类
/**
* 查询 某字段 等于 value 的值 可以指定从1-20,就是分页
*/
public <T> Observable<ArrayList<T>> queryByWhereLength(final Class<T> cls, final String where, final String[] value, final int start, final int length) {
return Observable.defer(new Func0<Observable<ArrayList<T>>>() {
@Override
public Observable<ArrayList<T>> call() {
return Observable.just(liteOrm.query(new QueryBuilder<T>(cls).where(where + "=?", value).limit(start, length)));
}
}).subscribeOn(Schedulers.io());
}
示例12: getLoseKey
import com.litesuits.orm.db.assit.QueryBuilder; //导入依赖的package包/类
@Override
public String getLoseKey() {
QueryBuilder query = new QueryBuilder(CacheEntry.class);
query.orderBy(CacheEntry.COL_USE_COUNT).appendOrderAscBy(CacheEntry.COL_LAST_USE_TIME);
query.limit(0, 1);
List<CacheEntry> list = getDb().query(query);
if (list != null && list.size() >0) {
return list.get(0).getKey();
} else {
return null;
}
}
示例13: getLoseKey
import com.litesuits.orm.db.assit.QueryBuilder; //导入依赖的package包/类
@Override
public String getLoseKey() {
QueryBuilder query = new QueryBuilder(CacheEntry.class);
query.orderBy(CacheEntry.COL_LAST_USE_TIME);
query.limit(0, 1);
List<CacheEntry> list = getDb().query(query);
if (list != null && list.size() >0) {
return list.get(0).getKey();
} else {
return null;
}
}
示例14: getLoseKey
import com.litesuits.orm.db.assit.QueryBuilder; //导入依赖的package包/类
@Override
public String getLoseKey() {
QueryBuilder query = new QueryBuilder(CacheEntry.class);
query.orderBy(CacheEntry.COL_CREATE_TIME);
query.limit(0, 1);
List<CacheEntry> list = getDb().query(query);
if (list != null && list.size() >0) {
return list.get(0).getKey();
} else {
return null;
}
}
示例15: checkWhetherCollected
import com.litesuits.orm.db.assit.QueryBuilder; //导入依赖的package包/类
private void checkWhetherCollected() {
QueryBuilder query = new QueryBuilder(GirlCollect.class).where("girlUrl = ?", new String[]{mMeizhiUrl});
long nums = MyApp.mLiteOrm.queryCount(query);
if (nums == 1) {
mFavFAB.setImageResource(R.mipmap.ab_fav_active);
mIsGirlCollected = true;
} else {
mIsGirlCollected = false;
}
}