当前位置: 首页>>代码示例>>Java>>正文


Java UpdateBuilder类代码示例

本文整理汇总了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;
                }
            });
        }
    });
}
 
开发者ID:aliyun,项目名称:aliyun-cloudphotos-android-demo,代码行数:26,代码来源:MyFace.java

示例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;
        }
    });
}
 
开发者ID:aliyun,项目名称:aliyun-cloudphotos-android-demo,代码行数:18,代码来源:MyFace.java

示例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;
        }
    });
}
 
开发者ID:aliyun,项目名称:aliyun-cloudphotos-android-demo,代码行数:25,代码来源:MyCursor.java

示例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;
        }
    });
}
 
开发者ID:aliyun,项目名称:aliyun-cloudphotos-android-demo,代码行数:18,代码来源:MyMoment.java

示例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;
        }
    });
}
 
开发者ID:aliyun,项目名称:aliyun-cloudphotos-android-demo,代码行数:18,代码来源:MyTag.java

示例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;
        }
    });
}
 
开发者ID:aliyun,项目名称:aliyun-cloudphotos-android-demo,代码行数:25,代码来源:MySetting.java

示例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;
        }
    });
}
 
开发者ID:aliyun,项目名称:aliyun-cloudphotos-android-demo,代码行数:18,代码来源:MyAlbum.java

示例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;
}
 
开发者ID:benniaobuguai,项目名称:android-project-gallery,代码行数:24,代码来源:GameRankingBiz.java

示例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();
    }
}
 
开发者ID:saveendhiman,项目名称:XMPPSample_Studio,代码行数:24,代码来源:DatabaseHelper.java

示例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();
    }

}
 
开发者ID:willylatorre,项目名称:restaurand,代码行数:18,代码来源:DatabaseHelper.java

示例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);
	}
}
 
开发者ID:Microsoft,项目名称:EmbeddedSocial-Android-SDK,代码行数:25,代码来源:ContentCache.java

示例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();
}

   }
 
开发者ID:learning-layers,项目名称:Expert-Identification-Service,代码行数:25,代码来源:DatabaseHandler.java

示例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;

}
 
开发者ID:keighrim,项目名称:mae-annotation,代码行数:18,代码来源:LocalSqliteDriverImpl.java

示例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;
}
 
开发者ID:nicky1525,项目名称:UniApp,代码行数:20,代码来源:DBHandler.java

示例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());
}
 
开发者ID:j256,项目名称:ormlite-jdbc,代码行数:22,代码来源:JdbcBaseDaoImplTest.java


注:本文中的com.j256.ormlite.stmt.UpdateBuilder类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。