本文整理汇总了Java中com.j256.ormlite.stmt.QueryBuilder类的典型用法代码示例。如果您正苦于以下问题:Java QueryBuilder类的具体用法?Java QueryBuilder怎么用?Java QueryBuilder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
QueryBuilder类属于com.j256.ormlite.stmt包,在下文中一共展示了QueryBuilder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateName
import com.j256.ormlite.stmt.QueryBuilder; //导入依赖的package包/类
public static void updateName(final long faceId, final String name, final DatabaseCallback callback) {
DatabaseHelper.getInstance().execute(new Runnable() {
@Override
public void run() {
final RuntimeExceptionDao<MyFace, Long> dao = DatabaseHelper.getInstance().getCachedRuntimeExceptionDao(MyFace.class);
QueryBuilder<MyFace, Long> qb = dao.queryBuilder();
dao.callBatchTasks(new Callable() {
@Override
public Void call() throws Exception {
try {
if (dao.idExists(faceId)) {
UpdateBuilder<MyFace, Long> ub = dao.updateBuilder();
ub.where().eq("id", faceId);
ub.updateColumnValue("name", name);
ub.update();
}
} catch (Exception e) {
Log.w(TAG, e.getMessage());
}
return null;
}
});
}
});
}
示例2: query
import com.j256.ormlite.stmt.QueryBuilder; //导入依赖的package包/类
public static void query(final long limit, final DatabaseCallback<MyFace> callback) {
DatabaseHelper.getInstance().execute(new Runnable() {
@Override
public void run() {
final RuntimeExceptionDao<MyFace, Long> dao = DatabaseHelper.getInstance().getCachedRuntimeExceptionDao(MyFace.class);
QueryBuilder<MyFace, Long> qb = dao.queryBuilder();
qb.orderBy("name", false);
if (limit > 0) {
qb.limit(limit);
}
List<MyFace> result = null;
try {
result = qb.query();
callback.onCompleted(0, result);
} catch (Exception e) {
Log.w(TAG, e.getMessage());
callback.onCompleted(1, null);
}
}
});
}
示例3: getById
import com.j256.ormlite.stmt.QueryBuilder; //导入依赖的package包/类
public static void getById(final long id, final DatabaseCallback<MyFace> callback) {
DatabaseHelper.getInstance().execute(new Runnable() {
@Override
public void run() {
final RuntimeExceptionDao<MyFace, Long> dao = DatabaseHelper.getInstance().getCachedRuntimeExceptionDao(MyFace.class);
QueryBuilder<MyFace, Long> qb = dao.queryBuilder();
try {
qb.where().eq("id", id);
callback.onCompleted(0, qb.query());
} catch (Exception e) {
Log.w(TAG, e.getMessage());
callback.onCompleted(1, null);
}
}
});
}
示例4: getMaxUploadedAt
import com.j256.ormlite.stmt.QueryBuilder; //导入依赖的package包/类
public static void getMaxUploadedAt(final DatabaseCallback<MyFace> callback) {
DatabaseHelper.getInstance().execute(new Runnable() {
@Override
public void run() {
final RuntimeExceptionDao<MyFace, Long> dao = DatabaseHelper.getInstance().getCachedRuntimeExceptionDao(MyFace.class);
QueryBuilder<MyFace, Long> qb = dao.queryBuilder();
try {
qb.orderBy("mtime", false);
qb.limit(1L);
List<MyFace> result = qb.query();
callback.onCompleted(0, result);
} catch (Exception e) {
Log.w(TAG, e.getMessage());
callback.onCompleted(1, null);
}
}
});
}
示例5: getByFaceSync
import com.j256.ormlite.stmt.QueryBuilder; //导入依赖的package包/类
private static List<Long> getByFaceSync(final long faceId) {
final RuntimeExceptionDao<MyFacePhoto, Long> daoFacePhoto = DatabaseHelper.getInstance().getCachedRuntimeExceptionDao(MyFacePhoto.class);
try {
QueryBuilder<MyFacePhoto, Long> facePhotoQb = daoFacePhoto.queryBuilder();
facePhotoQb.where().eq("faceId", faceId);
List<MyFacePhoto> facePhotos = facePhotoQb.query();
List<Long> photoIds = new ArrayList<>();
for (MyFacePhoto fp : facePhotos) {
photoIds.add(fp.photoId);
}
return photoIds;
} catch (Exception e) {
Log.w(TAG, e.getMessage());
return null;
}
}
示例6: getAll
import com.j256.ormlite.stmt.QueryBuilder; //导入依赖的package包/类
public static void getAll(final List<String> folderList, final DatabaseCallback<UploadedPhoto> callback) {
DatabaseHelper.getInstance().execute(new Runnable() {
@Override
public void run() {
try {
final RuntimeExceptionDao<UploadedPhoto, Long> dao = DatabaseHelper.getInstance().getCachedRuntimeExceptionDao(UploadedPhoto.class);
QueryBuilder<UploadedPhoto, Long> qb = dao.queryBuilder();
qb.where().in("folder", folderList);
if (callback != null) callback.onCompleted(0, qb.query());
} catch (Exception e) {
Log.w(TAG, e.getMessage());
if (callback != null) callback.onCompleted(1, null);
}
}
});
}
示例7: updateSync
import com.j256.ormlite.stmt.QueryBuilder; //导入依赖的package包/类
private static void updateSync(final String key, final String nextCursor) {
final RuntimeExceptionDao<MyCursor, Long> dao = DatabaseHelper.getInstance().getCachedRuntimeExceptionDao(MyCursor.class);
dao.callBatchTasks(new Callable() {
@Override
public Object call() throws Exception {
try {
QueryBuilder<MyCursor, Long> cursorQb = dao.queryBuilder();
cursorQb.where().eq("key", key);
List<MyCursor> cursor = cursorQb.query();
if (cursor != null && cursor.size() > 0) {
UpdateBuilder<MyCursor, Long> ub = dao.updateBuilder();
ub.where().eq("key", key);
ub.updateColumnValue("cursor", nextCursor);
ub.update();
} else {
dao.create(new MyCursor(key, nextCursor));
}
} catch (Exception e) {
Log.w(TAG, e.getMessage());
}
return null;
}
});
}
示例8: getNextCursor
import com.j256.ormlite.stmt.QueryBuilder; //导入依赖的package包/类
public static void getNextCursor(final String key, final DatabaseCallback<MyCursor> callback) {
DatabaseHelper.getInstance().execute(new Runnable() {
@Override
public void run() {
final RuntimeExceptionDao<MyCursor, Long> dao = DatabaseHelper.getInstance().getCachedRuntimeExceptionDao(MyCursor.class);
QueryBuilder<MyCursor, Long> qb = dao.queryBuilder();
try {
qb.where().eq("key", key);
callback.onCompleted(0, qb.query());
} catch (Exception e) {
Log.w(TAG, e.getMessage());
callback.onCompleted(1, null);
}
}
});
}
示例9: getById
import com.j256.ormlite.stmt.QueryBuilder; //导入依赖的package包/类
public static void getById(final long id, final DatabaseCallback<MyMoment> callback) {
DatabaseHelper.getInstance().execute(new Runnable() {
@Override
public void run() {
final RuntimeExceptionDao<MyMoment, Long> dao = DatabaseHelper.getInstance().getCachedRuntimeExceptionDao(MyMoment.class);
QueryBuilder<MyMoment, Long> qb = dao.queryBuilder();
try {
qb.where().eq("id", id);
qb.orderBy("takenAt", false);
if (callback != null) callback.onCompleted(0, qb.query());
} catch (Exception e) {
Log.w(TAG, e.getMessage());
if (callback != null) callback.onCompleted(1, null);
}
}
});
}
示例10: getByIds
import com.j256.ormlite.stmt.QueryBuilder; //导入依赖的package包/类
public static void getByIds(final List<Long> ids, final DatabaseCallback<MyMoment> callback) {
DatabaseHelper.getInstance().execute(new Runnable() {
@Override
public void run() {
final RuntimeExceptionDao<MyMoment, Long> dao = DatabaseHelper.getInstance().getCachedRuntimeExceptionDao(MyMoment.class);
QueryBuilder<MyMoment, Long> qb = dao.queryBuilder();
try {
qb.where().in("id", ids);
qb.orderBy("takenAt", false);
if (callback != null) callback.onCompleted(0, qb.query());
} catch (Exception e) {
Log.w(TAG, e.getMessage());
if (callback != null) callback.onCompleted(1, null);
}
}
});
}
示例11: getMaxUploadedAt
import com.j256.ormlite.stmt.QueryBuilder; //导入依赖的package包/类
public static void getMaxUploadedAt(final DatabaseCallback<MyMoment> callback) {
DatabaseHelper.getInstance().execute(new Runnable() {
@Override
public void run() {
final RuntimeExceptionDao<MyMoment, Long> dao = DatabaseHelper.getInstance().getCachedRuntimeExceptionDao(MyMoment.class);
QueryBuilder<MyMoment, Long> qb = dao.queryBuilder();
try {
qb.orderBy("mtime", false);
qb.limit(1L);
List<MyMoment> result = qb.query();
callback.onCompleted(0, result);
} catch (Exception e) {
Log.w(TAG, e.getMessage());
callback.onCompleted(1, null);
}
}
});
}
示例12: queryExceptSubTag
import com.j256.ormlite.stmt.QueryBuilder; //导入依赖的package包/类
public static void queryExceptSubTag(final long limit, final DatabaseCallback<MyTag> callback) {
DatabaseHelper.getInstance().execute(new Runnable() {
@Override
public void run() {
final RuntimeExceptionDao<MyTag, Long> dao = DatabaseHelper.getInstance().getCachedRuntimeExceptionDao(MyTag.class);
QueryBuilder<MyTag, Long> qb = dao.queryBuilder();
if (limit > 0) {
qb.limit(limit);
}
List<MyTag> result = null;
try {
qb.where().eq("isSubTag", false);
result = qb.query();
callback.onCompleted(0, result);
} catch (Exception e) {
Log.w(TAG, e.getMessage());
callback.onCompleted(1, null);
}
}
});
}
示例13: getById
import com.j256.ormlite.stmt.QueryBuilder; //导入依赖的package包/类
public static void getById(final long id, final DatabaseCallback<MyTag> callback) {
DatabaseHelper.getInstance().execute(new Runnable() {
@Override
public void run() {
final RuntimeExceptionDao<MyTag, Long> dao = DatabaseHelper.getInstance().getCachedRuntimeExceptionDao(MyTag.class);
QueryBuilder<MyTag, Long> qb = dao.queryBuilder();
try {
qb.where().eq("id", id);
callback.onCompleted(0, qb.query());
} catch (Exception e) {
Log.w(TAG, e.getMessage());
callback.onCompleted(1, null);
}
}
});
}
示例14: getByMomentSync
import com.j256.ormlite.stmt.QueryBuilder; //导入依赖的package包/类
private static List<Long> getByMomentSync(final long momentId) {
final RuntimeExceptionDao<MyMomentPhoto, Long> daoMomentPhoto = DatabaseHelper.getInstance().getCachedRuntimeExceptionDao(MyMomentPhoto.class);
try {
QueryBuilder<MyMomentPhoto, Long> momentPhotoQb = daoMomentPhoto.queryBuilder();
momentPhotoQb.where().eq("momentId", momentId);
List<MyMomentPhoto> momentPhotos = momentPhotoQb.query();
List<Long> photoIds = new ArrayList<>();
for (MyMomentPhoto mp : momentPhotos) {
photoIds.add(mp.photoId);
}
return photoIds;
} catch (Exception e) {
Log.w(TAG, e.getMessage());
return null;
}
}
示例15: getByTagSync
import com.j256.ormlite.stmt.QueryBuilder; //导入依赖的package包/类
private static List<Long> getByTagSync(final long tagId) {
final RuntimeExceptionDao<MyTagPhoto, Long> daoTagPhoto = DatabaseHelper.getInstance().getCachedRuntimeExceptionDao(MyTagPhoto.class);
try {
QueryBuilder<MyTagPhoto, Long> tagPhotoQb = daoTagPhoto.queryBuilder();
tagPhotoQb.where().eq("tagId", tagId);
List<MyTagPhoto> tagPhotos = tagPhotoQb.query();
List<Long> photoIds = new ArrayList<>();
for (MyTagPhoto tp : tagPhotos) {
photoIds.add(tp.photoId);
}
return photoIds;
} catch (Exception e) {
Log.w(TAG, e.getMessage());
return null;
}
}