com.j256.ormlite.stmt.UpdateBuilder Java Examples
The following examples show how to use
com.j256.ormlite.stmt.UpdateBuilder.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BaseDaoImplTest.java From ormlite-core with ISC License | 6 votes |
@Test public void testUpdateTwoDates() throws Exception { Dao<TwoDates, Integer> dao = createDao(TwoDates.class, true); TwoDates foo = new TwoDates(); long now = System.currentTimeMillis(); Date date1 = new Date(now); Date date2 = new Date(now + 1000); foo.date1 = date1; foo.date2 = date2; assertEquals(1, dao.create(foo)); UpdateBuilder<TwoDates, Integer> ub = dao.updateBuilder(); ub.updateColumnValue(TwoDates.FIELD_NAME_DATE1, date2); ub.updateColumnValue(TwoDates.FIELD_NAME_DATE2, date1); dao.update(ub.prepare()); }
Example #2
Source File: SetValueTest.java From ormlite-core with ISC License | 6 votes |
@Test public void testBasic() throws Exception { Dao<Foo, Integer> dao = createDao(Foo.class, true); Foo foo = new Foo(); int val = 66654654; foo.val = val; assertEquals(1, dao.create(foo)); Foo result = dao.queryForId(foo.id); assertNotNull(result); assertEquals(val, result.val); UpdateBuilder<Foo, Integer> up = dao.updateBuilder(); int newVal = 165445654; up.updateColumnValue(Foo.VAL_COLUMN_NAME, newVal); assertEquals(1, dao.update(up.prepare())); result = dao.queryForId(foo.id); assertNotNull(result); assertEquals(newVal, result.val); }
Example #3
Source File: SetValueTest.java From ormlite-core with ISC License | 6 votes |
@Test public void testSerializable() throws Exception { Dao<TestSerial, Integer> dao = createDao(TestSerial.class, true); TestSerial foo = new TestSerial(); String stuff = "hjrjpe"; foo.stuff = stuff; assertEquals(1, dao.create(foo)); TestSerial result = dao.queryForId(foo.id); assertNotNull(result); assertEquals(stuff, result.stuff); UpdateBuilder<TestSerial, Integer> up = dao.updateBuilder(); String newStuff = "165445654"; up.updateColumnValue("stuff", newStuff); assertEquals(1, dao.update(up.prepare())); result = dao.queryForId(foo.id); assertNotNull(result); assertEquals(newStuff, result.stuff); }
Example #4
Source File: BaseDaoImplTest.java From ormlite-core with ISC License | 6 votes |
@Test public void testUpdatePrepared() throws Exception { Dao<Foo, Integer> dao = createDao(Foo.class, true); Foo foo1 = new Foo(); assertEquals(1, dao.create(foo1)); Foo foo2 = new Foo(); assertEquals(1, dao.create(foo2)); int id3 = foo2.id + 1; assertNotNull(dao.queryForId(foo1.id)); assertNotNull(dao.queryForId(foo2.id)); assertNull(dao.queryForId(id3)); UpdateBuilder<Foo, Integer> updateBuilder = dao.updateBuilder(); updateBuilder.updateColumnValue(Foo.ID_COLUMN_NAME, id3); updateBuilder.where().eq(Foo.ID_COLUMN_NAME, foo1.id); assertEquals(1, dao.update(updateBuilder.prepare())); assertNull(dao.queryForId(foo1.id)); assertNotNull(dao.queryForId(foo2.id)); assertNotNull(dao.queryForId(id3)); assertEquals(2, dao.queryForAll().size()); }
Example #5
Source File: JdbcBaseDaoImplTest.java From ormlite-jdbc with ISC License | 6 votes |
@Test public void testPrepareStatementUpdateValueExpression() throws Exception { Dao<Foo, Integer> fooDao = createDao(Foo.class, true); Foo foo = new Foo(); foo.val = 123213; assertEquals(1, fooDao.create(foo)); QueryBuilder<Foo, Integer> stmtb = fooDao.queryBuilder(); stmtb.where().eq(Foo.ID_FIELD_NAME, foo.id); List<Foo> results = fooDao.query(stmtb.prepare()); assertEquals(1, results.size()); UpdateBuilder<Foo, Integer> updateb = fooDao.updateBuilder(); String stuff = "deopdjq"; updateb.updateColumnValue(Foo.STUFF_FIELD_NAME, stuff); StringBuilder sb = new StringBuilder(); updateb.escapeColumnName(sb, Foo.VAL_FIELD_NAME); sb.append("+ 1"); updateb.updateColumnExpression(Foo.VAL_FIELD_NAME, sb.toString()); assertEquals(1, fooDao.update(updateb.prepare())); results = fooDao.queryForAll(); assertEquals(1, results.size()); assertEquals(stuff, results.get(0).stuff); assertEquals(foo.val + 1, results.get(0).val); }
Example #6
Source File: JdbcBaseDaoImplTest.java From ormlite-jdbc with ISC License | 6 votes |
@Test public void testPrepareStatementUpdateValueNumber() throws Exception { Dao<Foo, Integer> fooDao = createDao(Foo.class, true); Foo foo = new Foo(); foo.val = 123213; assertEquals(1, fooDao.create(foo)); QueryBuilder<Foo, Integer> stmtb = fooDao.queryBuilder(); stmtb.where().eq(Foo.ID_FIELD_NAME, foo.id); List<Foo> results = fooDao.query(stmtb.prepare()); assertEquals(1, results.size()); UpdateBuilder<Foo, Integer> updateb = fooDao.updateBuilder(); updateb.updateColumnValue(Foo.VAL_FIELD_NAME, foo.val + 1); assertEquals(1, fooDao.update(updateb.prepare())); results = fooDao.query(stmtb.prepare()); assertEquals(1, results.size()); assertEquals(foo.val + 1, results.get(0).val); }
Example #7
Source File: JdbcBaseDaoImplTest.java From ormlite-jdbc with ISC License | 6 votes |
@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()); }
Example #8
Source File: BaseDaoImplTest.java From ormlite-core with ISC License | 6 votes |
@Test public void testRefresh() throws Exception { Dao<Foo, Integer> dao = createDao(Foo.class, true); Foo foo = new Foo(); int equal1 = 11312331; foo.equal = equal1; assertEquals(1, dao.create(foo)); int equal2 = 312312; assertNotNull(dao.queryForId(foo.id)); UpdateBuilder<Foo, Integer> updateBuilder = dao.updateBuilder(); updateBuilder.updateColumnValue(Foo.EQUAL_COLUMN_NAME, equal2); updateBuilder.where().eq(Foo.ID_COLUMN_NAME, foo.id); assertEquals(1, dao.update(updateBuilder.prepare())); assertEquals(equal1, foo.equal); assertEquals(1, dao.refresh(foo)); assertEquals(equal2, foo.equal); }
Example #9
Source File: LocalSqliteDriverImpl.java From mae-annotation with GNU General Public License v3.0 | 6 votes |
@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; }
Example #10
Source File: GameRankingBiz.java From android-project-wo2b with Apache License 2.0 | 6 votes |
/** * 把没有用户的数据更新为当前用户的信息 * * @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; }
Example #11
Source File: UserDao.java From FamilyChat with Apache License 2.0 | 6 votes |
/** * 更新某个用户的本地头像 * * @param phone 该用户手机号 * @param headPath 头像 * @return 更新成功后返回表中对应的行数,失败代表不存在该phone的数据 */ public int updateUserLocalHead(String phone, String headPath) { int lineNum = -1; try { UpdateBuilder<UserBean, Integer> updateBuilder = getDao().updateBuilder(); updateBuilder.updateColumnValue(UserDbConfig.LOCAL_HEAD, headPath); updateBuilder.where().eq(UserDbConfig.PHONE, phone); lineNum = getDao().update(updateBuilder.prepare()); } catch (SQLException e) { KLog.e(TAG + " UserDao.updateUserLocalHead fail : " + e.toString()); } return lineNum; }
Example #12
Source File: UserDao.java From FamilyChat with Apache License 2.0 | 6 votes |
/** * 将某个手机号的用户标记为已注册 * * @param phone 手机号 * @return 更新成功后返回表中对应的行数,失败代表不存在该phone的数据 */ public int updateUserAsRegisted(String phone) { int lineNum = -1; try { UpdateBuilder<UserBean, Integer> updateBuilder = getDao().updateBuilder(); updateBuilder.updateColumnValue(UserDbConfig.IS_REGIST, true); updateBuilder.where().eq(UserDbConfig.PHONE, phone); lineNum = getDao().update(updateBuilder.prepare()); } catch (SQLException e) { KLog.e(TAG + " UserDao.updateUserAsRegisted fail : " + e.toString()); } return lineNum; }
Example #13
Source File: OrmLiteDao.java From AndroidBase with Apache License 2.0 | 6 votes |
/** * 如果更新记录字段值为null则忽略不更新 * * @param t * @return */ private int updateIfValueNotNull(T t) throws SQLException, IllegalAccessException { UpdateBuilder updateBuilder = ormLiteDao.updateBuilder(); Map<String, Object> map = getFieldsIfValueNotNull(t); if (map.isEmpty()) { throw new SQLException("all field value is null."); } if (map.get("id") == null) { throw new SQLException("id is null."); } 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()); } return updateBuilder.update(); }
Example #14
Source File: DatabaseHelper.java From XMPPSample_Studio with Apache License 2.0 | 6 votes |
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(); } }
Example #15
Source File: SerializableTypeTest.java From ormlite-core with ISC License | 5 votes |
@Test public void testUpdateBuilderSerializable() throws Exception { Dao<SerializedUpdate, Integer> dao = createDao(SerializedUpdate.class, true); SerializedUpdate foo = new SerializedUpdate(); SerializedField serialized1 = new SerializedField("wow"); foo.serialized = serialized1; assertEquals(1, dao.create(foo)); SerializedUpdate result = dao.queryForId(foo.id); assertNotNull(result); assertNotNull(result.serialized); assertEquals(serialized1.foo, result.serialized.foo); // update with dao.update SerializedField serialized2 = new SerializedField("zip"); foo.serialized = serialized2; assertEquals(1, dao.update(foo)); result = dao.queryForId(foo.id); assertNotNull(result); assertNotNull(result.serialized); assertEquals(serialized2.foo, result.serialized.foo); // update with UpdateBuilder SerializedField serialized3 = new SerializedField("crack"); UpdateBuilder<SerializedUpdate, Integer> ub = dao.updateBuilder(); ub.updateColumnValue(SerializedUpdate.SERIALIZED_FIELD_NAME, serialized3); ub.where().idEq(foo.id); assertEquals(1, ub.update()); result = dao.queryForId(foo.id); assertNotNull(result); assertNotNull(result.serialized); assertEquals(serialized3.foo, result.serialized.foo); }
Example #16
Source File: BaseDaoImplTest.java From ormlite-core with ISC License | 5 votes |
@Test public void testUpdateTwoNulls() throws Exception { Dao<Foo, Integer> dao = createDao(Foo.class, true); UpdateBuilder<Foo, Integer> ub = dao.updateBuilder(); ub.updateColumnValue(Foo.STRING_COLUMN_NAME, null); ub.updateColumnValue(Foo.EQUAL_COLUMN_NAME, null); dao.update(ub.prepare()); }
Example #17
Source File: BaseDaoImplTest.java From ormlite-core with ISC License | 5 votes |
@Test public void testUpdateTwoNullsInSeperateStatements() throws Exception { Dao<Foo, Integer> dao = createDao(Foo.class, true); UpdateBuilder<Foo, Integer> ub = dao.updateBuilder(); ub.updateColumnValue(Foo.STRING_COLUMN_NAME, null); dao.update(ub.prepare()); ub = dao.updateBuilder(); ub.updateColumnValue(Foo.EQUAL_COLUMN_NAME, null); dao.update(ub.prepare()); }
Example #18
Source File: DBController.java From AndroidDownloader with Apache License 2.0 | 5 votes |
@Override public void pauseAllDownloading() { try { UpdateBuilder<MyDownloadInfLocal, String> myDownloadInfLocalIntegerUpdateBuilder = myDownloadInfLocalDao .updateBuilder(); myDownloadInfLocalIntegerUpdateBuilder.updateColumnValue("status", STATUS_PAUSED).where() .ne("status", STATUS_COMPLETED); myDownloadInfLocalIntegerUpdateBuilder.update(); } catch (SQLException e) { e.printStackTrace(); } }
Example #19
Source File: BaseDaoImplTest.java From ormlite-core with ISC License | 5 votes |
@Test(expected = SQLException.class) public void testUpdatePreparedThrow() throws Exception { Dao<Foo, Integer> dao = createDao(Foo.class, true); Foo foo = new Foo(); assertEquals(1, dao.create(foo)); DatabaseConnection conn = connectionSource.getReadWriteConnection(FOO_TABLE_NAME); try { conn.close(); UpdateBuilder<Foo, Integer> ub = dao.updateBuilder(); ub.updateColumnValue(Foo.EQUAL_COLUMN_NAME, 1); dao.update(ub.prepare()); } finally { connectionSource.releaseConnection(conn); } }
Example #20
Source File: DatabaseHelper.java From android-viewer-for-khan-academy with GNU General Public License v3.0 | 5 votes |
/** * Update a video's download_status in the database. * * Proxy to videoDao.update, but will not modify any fields but download_status. * Also updates the downloaded_video_count of all Topics in the video's parent * hierarchy. * * @param video The video to update. */ public void updateDownloadStatus(Video video, int was, int is) { Log.d(LOG_TAG, "updateDownloadStatus"); try { Dao<Video, String> videoDao = getVideoDao(); UpdateBuilder<Video, String> u = videoDao.updateBuilder(); u.updateColumnValue("download_status", is); u.where().eq("youtube_id", video.getYoutube_id()); videoDao.update(u.prepare()); // DEBUG // QueryBuilder<Video, String> q = videoDao.queryBuilder(); // q.where().eq("readable_id", video.getReadable_id()); // Video v = videoDao.queryForFirst(q.prepare()); // Log.d(LOG_TAG, String.format("updated dl status of %s from %d to %d", video.getTitle(), was, v.getDownload_status())); // Dao<Topic, String> topicDao = getTopicDao(); // UpdateBuilder<Topic, String> ub = topicDao.updateBuilder(); // ub.updateColumnExpression("downloaded_video_count", "downloaded_video_count + 1"); // Topic p = video.getParentTopic(); // while (p != null) { // topicDao.refresh(p); // Log.d(LOG_TAG, String.format("updating parent topic %s. Value was %d...", p.getTitle(), p.getDownloaded_video_count())); // ub.where().idEq(p.getId()); // PreparedUpdate<Topic> pu = ub.prepare(); // topicDao.update(pu); // // // DEBUG //// p = topicDao.queryForId(p.getId()); //// Log.d(LOG_TAG, String.format("updated to %d.", p.getDownloaded_video_count())); // // p = p.getParentTopic(); // } } catch (SQLException e) { e.printStackTrace(); } }
Example #21
Source File: DatabaseHelper.java From android-viewer-for-khan-academy with GNU General Public License v3.0 | 5 votes |
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(); } }
Example #22
Source File: JdbcBaseDaoImplTest.java From ormlite-jdbc with ISC License | 5 votes |
@Test public void testPrepareStatementUpdateValueWhere() throws Exception { Dao<Foo, Integer> fooDao = createDao(Foo.class, true); Foo foo1 = new Foo(); foo1.val = 78582351; assertEquals(1, fooDao.create(foo1)); Foo foo2 = new Foo(); String stuff = "eopqjdepodje"; foo2.stuff = stuff; foo2.val = 123344131; assertEquals(1, fooDao.create(foo2)); UpdateBuilder<Foo, Integer> updateb = fooDao.updateBuilder(); String newStuff = "deopdjq"; updateb.updateColumnValue(Foo.STUFF_FIELD_NAME, newStuff); StringBuilder sb = new StringBuilder(); updateb.escapeColumnName(sb, Foo.VAL_FIELD_NAME); sb.append("+ 1"); updateb.updateColumnExpression(Foo.VAL_FIELD_NAME, sb.toString()); updateb.where().eq(Foo.ID_FIELD_NAME, foo2.id); assertEquals(1, fooDao.update(updateb.prepare())); List<Foo> results = fooDao.queryForAll(); assertEquals(2, results.size()); Foo foo = results.get(0); assertEquals(foo1.id, foo.id); assertEquals(foo1.val, foo.val); assertNull(foo.stuff); foo = results.get(1); assertEquals(foo2.id, foo.id); assertEquals(foo2.val + 1, foo.val); assertEquals(newStuff, foo.stuff); }
Example #23
Source File: DataPersisterMain.java From ormlite-jdbc with ISC License | 5 votes |
/** * Read and write some example data. */ private void readWriteData() throws Exception { // create an instance of User String name = "Jim Coakley"; Date birthDate = new Date(); DateTime createDateTime = new DateTime().plusDays(10); User user = new User(name, birthDate, createDateTime); // persist the user object to the database userDao.create(user); // if we get the user from the database then we should User result = userDao.queryForId(user.getId()); // our result birth-date should now be null because it is too early assertEquals(birthDate, result.getBirthDate()); assertEquals(createDateTime, result.getCreateDateTime()); // to simulate a 'zero-date' we update the database by hand UpdateBuilder<User, Integer> ub = userDao.updateBuilder(); // set it to some silly value ub.updateColumnExpression(User.FIELD_BIRTH_DATE, "'0000-01-01'"); assertEquals(1, ub.update()); // now we pull back out the user to see if we get a null birth-date result = userDao.queryForId(user.getId()); // our result birth-date should now be null because it is too early assertNull(result.getBirthDate()); }
Example #24
Source File: CoursePreviewInfo.java From file-downloader with Apache License 2.0 | 5 votes |
@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(); } } } }
Example #25
Source File: InviteDao.java From FamilyChat with Apache License 2.0 | 5 votes |
/** * 将所有未读通知设置为已读 */ public void setAllNotifyRead() { try { UpdateBuilder<InviteBean, Integer> updateBuilder = getDao().updateBuilder(); updateBuilder.where().eq(InviteDbConfig.READ, false); updateBuilder.updateColumnValue(InviteDbConfig.READ, true); getDao().update(updateBuilder.prepare()); } catch (SQLException e) { KLog.e(TAG + "InviteDao.setAllNotifyRead fail:" + e.toString()); } }
Example #26
Source File: RuntimeExceptionDao.java From ormlite-core with ISC License | 4 votes |
/** * @see Dao#updateBuilder() */ @Override public UpdateBuilder<T, ID> updateBuilder() { return dao.updateBuilder(); }
Example #27
Source File: BaseDaoImpl.java From ormlite-core with ISC License | 4 votes |
@Override public UpdateBuilder<T, ID> updateBuilder() { checkForInitialized(); return new UpdateBuilder<T, ID>(databaseType, tableInfo, this); }
Example #28
Source File: UserDao.java From FamilyChat with Apache License 2.0 | 4 votes |
/** * 更新某个用户的昵称 * * @param userBean 更新数据 * @return 更新成功后返回表中对应的行数,失败代表不存在该phone的数据 */ public int updateUserName(UserBean userBean) { int lineNum = -1; try { UpdateBuilder<UserBean, Integer> updateBuilder = getDao().updateBuilder(); String nameApp = userBean.getNameApp(); String nameSystem = userBean.getNameSystem(); //新数据对象中如果app备注名不为空,则所有姓名相关字段都需要更新 if (StringUtil.isNotEmpty(nameApp)) { updateBuilder.updateColumnValue(UserDbConfig.NAME_APP, userBean.getNameApp()); updateBuilder.updateColumnValue(UserDbConfig.NAME_SYSTEM, userBean.getNameSystem()); updateBuilder.updateColumnValue(UserDbConfig.DISPLAY_NAME, userBean.getDisplayName()); updateBuilder.updateColumnValue(UserDbConfig.FIRST_CHAR, userBean.getFirstChar()); updateBuilder.updateColumnValue(UserDbConfig.SIMPLE_SPELL, userBean.getSimpleSpell()); updateBuilder.updateColumnValue(UserDbConfig.FULL_SPELL, userBean.getFullSpell()); } //新数据对象中系统备注名不为空,需要对比老数据 else if (StringUtil.isNotEmpty(nameSystem)) { UserBean localBean = queryUserByPhone(userBean.getPhone()); if (localBean != null) { //老数据中app备注名不为空,则只需更新系统备注名 if (StringUtil.isNotEmpty(localBean.getNameApp())) { updateBuilder.updateColumnValue(UserDbConfig.NAME_SYSTEM, userBean.getNameSystem()); } //除了app备注名其余都更新 else { updateBuilder.updateColumnValue(UserDbConfig.NAME_SYSTEM, userBean.getNameSystem()); updateBuilder.updateColumnValue(UserDbConfig.DISPLAY_NAME, userBean.getDisplayName()); updateBuilder.updateColumnValue(UserDbConfig.FIRST_CHAR, userBean.getFirstChar()); updateBuilder.updateColumnValue(UserDbConfig.SIMPLE_SPELL, userBean.getSimpleSpell()); updateBuilder.updateColumnValue(UserDbConfig.FULL_SPELL, userBean.getFullSpell()); } } } updateBuilder.where().eq(UserDbConfig.PHONE, userBean.getPhone()); lineNum = getDao().update(updateBuilder.prepare()); } catch (SQLException e) { KLog.e(TAG + " UserDao.updateUserName fail : " + e.toString()); } return lineNum; }
Example #29
Source File: MetadataReferenceDao.java From geopackage-core-java with MIT License | 3 votes |
/** * Remove metadata references (by updating the field to null) with foreign * keys to the metadata parent id * * @param parentId * parent id * @return updated count * @throws SQLException * upon failure */ public int removeMetadataParent(long parentId) throws SQLException { UpdateBuilder<MetadataReference, Void> ub = updateBuilder(); ub.updateColumnValue(MetadataReference.COLUMN_PARENT_ID, null); ub.where().eq(MetadataReference.COLUMN_PARENT_ID, parentId); PreparedUpdate<MetadataReference> update = ub.prepare(); int updated = update(update); return updated; }
Example #30
Source File: Dao.java From ormlite-core with ISC License | 2 votes |
/** * Like {@link #queryBuilder()} but allows you to build an UPDATE statement. You can then call call * {@link UpdateBuilder#prepare()} and pass the returned {@link PreparedUpdate} to {@link #update(PreparedUpdate)}. */ public UpdateBuilder<T, ID> updateBuilder();