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


Java UpdateBuilder.escapeColumnName方法代码示例

本文整理汇总了Java中com.j256.ormlite.stmt.UpdateBuilder.escapeColumnName方法的典型用法代码示例。如果您正苦于以下问题:Java UpdateBuilder.escapeColumnName方法的具体用法?Java UpdateBuilder.escapeColumnName怎么用?Java UpdateBuilder.escapeColumnName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.j256.ormlite.stmt.UpdateBuilder的用法示例。


在下文中一共展示了UpdateBuilder.escapeColumnName方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

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

示例2: 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);
}
 
开发者ID:j256,项目名称:ormlite-android-tests,代码行数:26,代码来源:AndroidJdbcBaseDaoImplTest.java

示例3: testPrepareStatementUpdateValueWhere

import com.j256.ormlite.stmt.UpdateBuilder; //导入方法依赖的package包/类
@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);
}
 
开发者ID:j256,项目名称:ormlite-jdbc,代码行数:34,代码来源:JdbcBaseDaoImplTest.java

示例4: testPrepareStatementUpdateValueWhere

import com.j256.ormlite.stmt.UpdateBuilder; //导入方法依赖的package包/类
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);
}
 
开发者ID:j256,项目名称:ormlite-android-tests,代码行数:33,代码来源:AndroidJdbcBaseDaoImplTest.java


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