本文整理汇总了Java中com.j256.ormlite.stmt.UpdateBuilder.updateColumnValue方法的典型用法代码示例。如果您正苦于以下问题:Java UpdateBuilder.updateColumnValue方法的具体用法?Java UpdateBuilder.updateColumnValue怎么用?Java UpdateBuilder.updateColumnValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.j256.ormlite.stmt.UpdateBuilder
的用法示例。
在下文中一共展示了UpdateBuilder.updateColumnValue方法的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: 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();
}
}
示例4: 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;
}
示例5: 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;
}
示例6: 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());
}
示例7: testPrepareStatementUpdateValueNumber
import com.j256.ormlite.stmt.UpdateBuilder; //导入方法依赖的package包/类
@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);
}
示例8: testPrepareStatementUpdateValueExpression
import com.j256.ormlite.stmt.UpdateBuilder; //导入方法依赖的package包/类
@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);
}
示例9: testPrepareStatementUpdateValueString
import com.j256.ormlite.stmt.UpdateBuilder; //导入方法依赖的package包/类
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());
}
示例10: testPrepareStatementUpdateValueNumber
import com.j256.ormlite.stmt.UpdateBuilder; //导入方法依赖的package包/类
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);
}
示例11: testPrepareStatementUpdateValueExpression
import com.j256.ormlite.stmt.UpdateBuilder; //导入方法依赖的package包/类
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);
}
示例12: testBasic
import com.j256.ormlite.stmt.UpdateBuilder; //导入方法依赖的package包/类
@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);
}
示例13: testSerializable
import com.j256.ormlite.stmt.UpdateBuilder; //导入方法依赖的package包/类
@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);
}
示例14: testUpdatePrepared
import com.j256.ormlite.stmt.UpdateBuilder; //导入方法依赖的package包/类
@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());
}
示例15: testUpdateTwoDates
import com.j256.ormlite.stmt.UpdateBuilder; //导入方法依赖的package包/类
@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());
}