本文整理汇总了Java中com.j256.ormlite.stmt.UpdateBuilder.update方法的典型用法代码示例。如果您正苦于以下问题:Java UpdateBuilder.update方法的具体用法?Java UpdateBuilder.update怎么用?Java UpdateBuilder.update使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.j256.ormlite.stmt.UpdateBuilder
的用法示例。
在下文中一共展示了UpdateBuilder.update方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: 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();
}
}
示例3: 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);
}
}
示例4: 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();
}
}
示例5: 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;
}
示例6: 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;
}
示例7: pauseAllDownloading
import com.j256.ormlite.stmt.UpdateBuilder; //导入方法依赖的package包/类
@Override
public void pauseAllDownloading() {
try {
UpdateBuilder<MyDownloadInfLocal, Integer> myDownloadInfLocalIntegerUpdateBuilder = myDownloadInfLocalDao
.updateBuilder();
myDownloadInfLocalIntegerUpdateBuilder.updateColumnValue("status", STATUS_PAUSED).where()
.ne("status", STATUS_COMPLETED);
myDownloadInfLocalIntegerUpdateBuilder.update();
} catch (SQLException e) {
e.printStackTrace();
}
}
示例8: increaseRestaurantRndFactor
import com.j256.ormlite.stmt.UpdateBuilder; //导入方法依赖的package包/类
@Override
public void increaseRestaurantRndFactor(Restaurand restaurand) {
UpdateBuilder<Restaurand, Integer> ub = restauREDao.updateBuilder();
try {
ub.where().eq("id", restaurand.getId());
//Aumentamos 1 el valor rnd_factor
double rf = restaurand.getRandom_factor();
rf++;
ub.updateColumnValue("RND_FACTOR", rf);
ub.update();
} catch (SQLException e) {
e.printStackTrace();
}
}
示例9: updateIfValueNotNull
import com.j256.ormlite.stmt.UpdateBuilder; //导入方法依赖的package包/类
/**
* 如果更新记录字段值为null则忽略不更新
*
* @param t
* @return
*/
private int updateIfValueNotNull(T t) {
int result = 0;
UpdateBuilder updateBuilder = ormLiteDao.updateBuilder();
Map<String, Object> map = getFieldsIfValueNotNull(t);
if (map.isEmpty()) {
LogUtils.w("all field value is null.");
return 0;
}
if (map.get("id") == null) {
LogUtils.w("id is null.");
return 0;
}
try {
updateBuilder.where().idEq(map.get("id"));
for (Map.Entry<String, Object> entry : map.entrySet()) {
if (entry.getKey().equals("id")) {
continue;
}
updateBuilder.updateColumnValue(entry.getKey(), entry.getValue());
}
result = updateBuilder.update();
} catch (SQLException e) {
LogUtils.e(e);
}
return result;
}
示例10: onDownloadFileUpdated
import com.j256.ormlite.stmt.UpdateBuilder; //导入方法依赖的package包/类
@Override
public void onDownloadFileUpdated(DownloadFileInfo downloadFileInfo, Type type) {
if (downloadFileInfo != null && downloadFileInfo.getUrl() != null && downloadFileInfo.getUrl().equals
(mCourseUrl)) {
if (this.mDownloadFileInfo == null) {
try {
if (mCourseDbHelper == null) {
return;
}
UpdateBuilder builder = mCourseDbHelper.getDao(CoursePreviewInfo.class).updateBuilder();
builder.where().eq(CoursePreviewInfo.COLUMN_NAME_OF_FIELD_COURSE_URL, downloadFileInfo.getUrl());
int result = builder.update();
if (result == 1) {
this.mDownloadFileInfo = downloadFileInfo;
} else {
Dao<CoursePreviewInfo, Integer> dao = mCourseDbHelper.getDao(CoursePreviewInfo.class);
CreateOrUpdateStatus status = dao.createOrUpdate(this);
if (status.isCreated() || status.isUpdated()) {
this.mDownloadFileInfo = downloadFileInfo;
}
}
} catch (SQLException e) {
e.printStackTrace();
}
}
}
}
示例11: markPostType
import com.j256.ormlite.stmt.UpdateBuilder; //导入方法依赖的package包/类
public void markPostType() {
ConnectionSource source = super.getConnectionSource();
try {
Dao<DataEntity, Long> DataDao = DaoManager.createDao(source, DataEntity.class);
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());
// System.out.println(entity.getTitle());
if (text != null && text.startsWith("Re:")) {
// System.out.println("Its an Ans:: ");
updateBuilder.updateColumnValue("post_type_id", 2);
} else {
System.out.println("Q:: " + text);
updateBuilder.updateColumnValue("post_type_id", 1);
}
updateBuilder.update();
}
} catch (SQLException e) {
e.printStackTrace();
}
}
示例12: updateAllAssignmentsInGroup
import com.j256.ormlite.stmt.UpdateBuilder; //导入方法依赖的package包/类
public int updateAllAssignmentsInGroup(long groupId, Assignment.Status status) {
try {
QueryBuilder<Member, Long> groupMembersQuery =
mDbHelper.getDaoEx(Member.class).queryBuilder();
groupMembersQuery.selectColumns(Member.Columns._ID).where().eq(Member.Columns.GROUP_ID_COLUMN, groupId);
UpdateBuilder<Assignment, Long> updateBuilder =
mDbHelper.getDaoEx(Assignment.class).updateBuilder();
updateBuilder.updateColumnValue(Assignment.Columns.SEND_STATUS_COLUMN, status).
where().in(Assignment.Columns.GIVER_MEMBER_ID_COLUMN, groupMembersQuery);
return updateBuilder.update();
} catch (java.sql.SQLException e) {
throw new SQLException(e.getMessage());
}
}
示例13: updateGroupName
import com.j256.ormlite.stmt.UpdateBuilder; //导入方法依赖的package包/类
public int updateGroupName(long groupId, String groupName) {
try {
// Escape the group name
SelectArg selectArg = new SelectArg();
selectArg.setValue(groupName);
UpdateBuilder<Group, Long> updateBuilder =
mDbHelper.getDaoEx(Group.class).updateBuilder();
updateBuilder.updateColumnValue(Group.Columns.NAME_COLUMN, selectArg).
where().eq(Group.Columns._ID, groupId);
return updateBuilder.update();
} catch (java.sql.SQLException e) {
throw new SQLException(e.getMessage());
}
}
示例14: migrateToMultiPatient
import com.j256.ormlite.stmt.UpdateBuilder; //导入方法依赖的package包/类
/**
* Method that migrate models to multi-user
*/
private void migrateToMultiPatient() throws SQLException {
// add patient column to routines, schedules and medicines
getRoutinesDao().executeRaw("ALTER TABLE Routines ADD COLUMN Patient INTEGER;");
getRoutinesDao().executeRaw("ALTER TABLE Medicines ADD COLUMN Patient INTEGER;");
getRoutinesDao().executeRaw("ALTER TABLE Schedules ADD COLUMN Patient INTEGER;");
getRoutinesDao().executeRaw("ALTER TABLE DailyScheduleItems ADD COLUMN Patient INTEGER;");
getRoutinesDao().executeRaw("ALTER TABLE DailyScheduleItems ADD COLUMN Date TEXT;");
Patient p = createDefaultPatient();
// PreferenceUtils.edit().putLong(PatientDao.PREFERENCE_ACTIVE_PATIENT, p.id()).commit();
// Assign all routines to the default patient
UpdateBuilder<Routine, Long> rUpdateBuilder = getRoutinesDao().updateBuilder();
rUpdateBuilder.updateColumnValue(Routine.COLUMN_PATIENT, p.getId());
rUpdateBuilder.update();
// Assign all schedules to the default patient
UpdateBuilder<Schedule, Long> sUpdateBuilder = getSchedulesDao().updateBuilder();
sUpdateBuilder.updateColumnValue(Schedule.COLUMN_PATIENT, p.getId());
sUpdateBuilder.update();
// Assign all medicines to the default patient
UpdateBuilder<Medicine, Long> mUpdateBuilder = getMedicinesDao().updateBuilder();
mUpdateBuilder.updateColumnValue(Medicine.COLUMN_PATIENT, p.getId());
mUpdateBuilder.update();
// Assign all DailyScheduleItems to the default patient, for today
UpdateBuilder<DailyScheduleItem, Long> siUpdateBuilder = getDailyScheduleItemsDao().updateBuilder();
siUpdateBuilder.updateColumnValue(DailyScheduleItem.COLUMN_PATIENT, p.getId());
siUpdateBuilder.update();
// date formatter changes on v11, so we can no use LocalDatePersister here
String now = LocalDate.now().toString("ddMMYYYY");
String updateDateSql = "UPDATE DailyScheduleItems SET " + DailyScheduleItem.COLUMN_DATE + " = '" + now + "'";
getDailyScheduleItemsDao().executeRaw(updateDateSql);
}
示例15: resetDownloadStatusAndDlmId
import com.j256.ormlite.stmt.UpdateBuilder; //导入方法依赖的package包/类
private void resetDownloadStatusAndDlmId(long dlm_id) {
try {
UpdateBuilder<Video, String> q = getVideoDao().updateBuilder();
q.where().eq("dlm_id", dlm_id);
q.updateColumnValue("dlm_id", 0);
q.updateColumnValue("download_status", Video.DL_STATUS_NOT_STARTED);
q.update();
} catch (SQLException e) {
e.printStackTrace();
}
}