本文整理汇总了Java中com.j256.ormlite.stmt.UpdateBuilder类的典型用法代码示例。如果您正苦于以下问题:Java UpdateBuilder类的具体用法?Java UpdateBuilder怎么用?Java UpdateBuilder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
UpdateBuilder类属于com.j256.ormlite.stmt包,在下文中一共展示了UpdateBuilder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateName
import com.j256.ormlite.stmt.UpdateBuilder; //导入依赖的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: updateNextCursorSync
import com.j256.ormlite.stmt.UpdateBuilder; //导入依赖的package包/类
public static void updateNextCursorSync(final MyFace face) {
final RuntimeExceptionDao<MyFace, Long> dao = DatabaseHelper.getInstance().getCachedRuntimeExceptionDao(MyFace.class);
dao.callBatchTasks(new Callable<Object>() {
@Override
public Object call() throws Exception {
try {
UpdateBuilder<MyFace, Long> ub = dao.updateBuilder();
ub.where().eq("id", face.id);
ub.updateColumnValue("nextCursor", face.nextCursor);
ub.update();
} catch (Exception e) {
Log.w(TAG, e.getMessage());
}
return null;
}
});
}
示例3: updateSync
import com.j256.ormlite.stmt.UpdateBuilder; //导入依赖的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;
}
});
}
示例4: updateNextCursorSync
import com.j256.ormlite.stmt.UpdateBuilder; //导入依赖的package包/类
public static void updateNextCursorSync(final MyMoment moment) {
final RuntimeExceptionDao<MyMoment, Long> dao = DatabaseHelper.getInstance().getCachedRuntimeExceptionDao(MyMoment.class);
dao.callBatchTasks(new Callable<Object>() {
@Override
public Object call() throws Exception {
try {
UpdateBuilder<MyMoment, Long> ub = dao.updateBuilder();
ub.where().eq("id", moment.id);
ub.updateColumnValue("nextCursor", moment.nextCursor);
ub.update();
} catch (Exception e) {
Log.w(TAG, e.getMessage());
}
return null;
}
});
}
示例5: updateNextCursorSync
import com.j256.ormlite.stmt.UpdateBuilder; //导入依赖的package包/类
public static void updateNextCursorSync(final MyTag tag) {
final RuntimeExceptionDao<MyTag, Long> dao = DatabaseHelper.getInstance().getCachedRuntimeExceptionDao(MyTag.class);
dao.callBatchTasks(new Callable<Object>() {
@Override
public Object call() throws Exception {
try {
UpdateBuilder<MyTag, Long> ub = dao.updateBuilder();
ub.where().eq("id", tag.id);
ub.updateColumnValue("nextCursor", tag.nextCursor);
ub.update();
} catch (Exception e) {
Log.w(TAG, e.getMessage());
}
return null;
}
});
}
示例6: updateSync
import com.j256.ormlite.stmt.UpdateBuilder; //导入依赖的package包/类
private static void updateSync(final String key, final String value) {
final RuntimeExceptionDao<MySetting, Long> dao = DatabaseHelper.getInstance().getCachedRuntimeExceptionDao(MySetting.class);
dao.callBatchTasks(new Callable() {
@Override
public Object call() throws Exception {
try {
QueryBuilder<MySetting, Long> settingQb = dao.queryBuilder();
settingQb.where().eq("key", key);
List<MySetting> settings = settingQb.query();
if (settings != null && settings.size() > 0) {
UpdateBuilder<MySetting, Long> ub = dao.updateBuilder();
ub.where().eq("key", key);
ub.updateColumnValue("value", value);
ub.update();
} else {
dao.create(new MySetting(key, value));
}
} catch (Exception e) {
Log.w(TAG, e.getMessage());
}
return null;
}
});
}
示例7: updateNextCursorSync
import com.j256.ormlite.stmt.UpdateBuilder; //导入依赖的package包/类
public static void updateNextCursorSync(final MyAlbum album) {
final RuntimeExceptionDao<MyAlbum, Long> dao = DatabaseHelper.getInstance().getCachedRuntimeExceptionDao(MyAlbum.class);
dao.callBatchTasks(new Callable<Object>() {
@Override
public Object call() throws Exception {
try {
UpdateBuilder<MyAlbum, Long> ub = dao.updateBuilder();
ub.where().eq("id", album.id);
ub.updateColumnValue("nextCursor", album.nextCursor);
ub.update();
} catch (Exception e) {
Log.w(TAG, e.getMessage());
}
return null;
}
});
}
示例8: updateRecordToNewUser
import com.j256.ormlite.stmt.UpdateBuilder; //导入依赖的package包/类
/**
* 把没有用户的数据更新为当前用户的信息
*
* @param userName
*/
public int updateRecordToNewUser(String userName)
{
UpdateBuilder<GameRanking, ?> ub = getDao().updateBuilder();
try
{
ub.updateColumnValue("user_name", userName);
ub.updateColumnValue("nickname", userName);
ub.where().isNull("user_name").or().eq("user_name", "");
return ub.update();
}
catch (SQLException e)
{
e.printStackTrace();
}
return -1;
}
示例9: updateContactStatus
import com.j256.ormlite.stmt.UpdateBuilder; //导入依赖的package包/类
public void updateContactStatus(final String jid, final String status,
final int mood) {
try {
TransactionManager.callInTransaction(getConnectionSource(),
new Callable<Void>() {
public Void call() throws Exception {
UpdateBuilder<ContactItem, ?> builder = getDao(
ContactItem.class).updateBuilder();
builder.updateColumnValue("status", status);
builder.updateColumnValue("mood", mood);
builder.where().eq("username",
JidCreate.bareFrom(jid));
getDao(ContactItem.class).update(builder.prepare());
return (Void) null;
}
});
return;
} catch (SQLException localSQLException) {
localSQLException.printStackTrace();
}
}
示例10: updateRestaurantRndFactor
import com.j256.ormlite.stmt.UpdateBuilder; //导入依赖的package包/类
@Override
public void updateRestaurantRndFactor(Restaurand restaurand) {
UpdateBuilder<Restaurand, Integer> ub = restauREDao.updateBuilder();
try {
ub.where().eq("id", restaurand.getId());
//Recuperamos el mayor valor de random_factor
double max = restauREDao.queryRawValue("select max(RND_FACTOR) from restaurand");
max = max + 0.1;
ub.updateColumnValue("RND_FACTOR", max);
ub.updateColumnValue("LAST_SELECTED", new Date());
ub.update();
} catch (SQLException e) {
e.printStackTrace();
}
}
示例11: removeComment
import com.j256.ormlite.stmt.UpdateBuilder; //导入依赖的package包/类
/**
* Removes a comment.
* @param commentHandle comment handle
*/
public void removeComment(String commentHandle) {
DeleteBuilder<CommentFeedRelation, Integer> deleteBuilder = commentFeedDao.deleteBuilder();
try {
String topicHandle = getCommentParentHandle(commentHandle);
deleteBuilder.where().eq(DbSchemas.CommentFeedRelation.COMMENT_HANDLE, commentHandle);
deleteBuilder.delete();
if (!TextUtils.isEmpty(topicHandle)) {
UpdateBuilder<TopicView, String> updateBuilder = topicDao.updateBuilder();
updateBuilder.where()
.eq(DbSchemas.Topics.TOPIC_HANDLE, topicHandle)
.and().gt(DbSchemas.Topics.TOTAL_COMMENTS, 0);
updateBuilder.updateColumnExpression(
DbSchemas.Topics.TOTAL_COMMENTS,
DbSchemas.Topics.TOTAL_COMMENTS + " - 1");
updateBuilder.update();
}
} catch (SQLException e) {
DebugLog.logException(e);
}
}
示例12: markPostType
import com.j256.ormlite.stmt.UpdateBuilder; //导入依赖的package包/类
public void markPostType(String datasetName) {
ConnectionSource source = super.getConnectionSource();
try {
Dao<DataEntity, Long> DataDao = DaoManager.createDao(source, getEntityConfigOfDataSet(source, DataEntity.class, datasetName) );
List<DataEntity> dataEntities = DataDao.queryForAll();
UpdateBuilder<DataEntity, Long> updateBuilder = DataDao.updateBuilder();
for (DataEntity entity : dataEntities) {
String text = entity.getTitle();
updateBuilder.where().eq("post_id", entity.getPostId());
if (text != null && text.startsWith("Re:")) {
updateBuilder.updateColumnValue("post_type_id", 2);
} else {
updateBuilder.updateColumnValue("post_type_id", 1);
}
updateBuilder.update();
}
} catch (SQLException e) {
e.printStackTrace();
}
}
示例13: updateTagText
import com.j256.ormlite.stmt.UpdateBuilder; //导入依赖的package包/类
@Override
public boolean updateTagText(ExtentTag tag, String text) throws MaeDBException {
try {
UpdateBuilder<ExtentTag, String> updateBuilder = eTagDao.updateBuilder();
updateBuilder.where().eq(TAB_TAG_COL_TID, tag.getId());
updateBuilder.updateColumnValue(TAB_ETAG_COL_TEXT, text);
if (updateBuilder.update() == 1) {
setAnnotationChanged(true);
eTagDao.refresh(tag);
return true;
}
} catch (SQLException e) {
e.printStackTrace();
}
return false;
}
示例14: updateEsameById
import com.j256.ormlite.stmt.UpdateBuilder; //导入依赖的package包/类
@Override
public boolean updateEsameById(Bundle bundle) throws SQLException {
if (this.databaseHelper != null && this.databaseHelper.isOpen() && bundle != null) {
UpdateBuilder<EsameEntity, Integer> updateBuilder = databaseHelper.getEsameEntityDao().updateBuilder();
updateBuilder.where().eq(EsameEntity.ID, bundle.getStringArrayList(UpdateEsame.KEY2).get(0));
updateBuilder.updateColumnValue(EsameEntity.DATA, bundle.getStringArrayList(UpdateEsame.KEY2).get(1).toString());
updateBuilder.updateColumnValue(EsameEntity.NOME, bundle.getStringArrayList(UpdateEsame.KEY2).get(2).toString());
updateBuilder.updateColumnValue(EsameEntity.TOTCRED, bundle.getStringArrayList(UpdateEsame.KEY2).get(3).toString());
updateBuilder.updateColumnValue(EsameEntity.VOTO, bundle.getStringArrayList(UpdateEsame.KEY2).get(4).toString());
updateBuilder.updateColumnValue(EsameEntity.CREDACQ, bundle.getStringArrayList(UpdateEsame.KEY2).get(5).toString());
updateBuilder.update();
return true;
}
return false;
}
示例15: testPrepareStatementUpdateValueString
import com.j256.ormlite.stmt.UpdateBuilder; //导入依赖的package包/类
@Test
public void testPrepareStatementUpdateValueString() throws Exception {
Dao<Foo, Integer> fooDao = createDao(Foo.class, true);
Foo foo = new Foo();
String stuff = "dqedqdq";
foo.stuff = stuff;
assertEquals(1, fooDao.create(foo));
QueryBuilder<Foo, Integer> stmtb = fooDao.queryBuilder();
stmtb.where().eq(Foo.STUFF_FIELD_NAME, stuff);
List<Foo> results = fooDao.query(stmtb.prepare());
assertEquals(1, results.size());
UpdateBuilder<Foo, Integer> updateb = fooDao.updateBuilder();
String newStuff = "fepojefpjo";
updateb.updateColumnValue(Foo.STUFF_FIELD_NAME, newStuff);
assertEquals(1, fooDao.update(updateb.prepare()));
results = fooDao.query(stmtb.prepare());
assertEquals(0, results.size());
}