本文整理了Java中com.j256.ormlite.stmt.Where.<init>()
方法的一些代码示例,展示了Where.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Where.<init>()
方法的具体详情如下:
包路径:com.j256.ormlite.stmt.Where
类名称:Where
方法名:<init>
暂无
代码示例来源:origin: com.j256.ormlite/ormlite-core
/**
* Creates and returns a new {@link Where} object for this QueryBulder that can be used to add WHERE clauses to the
* SQL statement. Only one {@link Where} object can be associated with a QueryBuilder at a time and calling this
* method again creates a new {@link Where} object and resets the where information for this QueryBuilder.
*/
public Where<T, ID> where() {
where = new Where<T, ID>(tableInfo, this, databaseType);
return where;
}
代码示例来源:origin: j256/ormlite-core
/**
* Creates and returns a new {@link Where} object for this QueryBulder that can be used to add WHERE clauses to the
* SQL statement. Only one {@link Where} object can be associated with a QueryBuilder at a time and calling this
* method again creates a new {@link Where} object and resets the where information for this QueryBuilder.
*/
public Where<T, ID> where() {
where = new Where<T, ID>(tableInfo, this, databaseType);
return where;
}
代码示例来源:origin: j256/ormlite-core
@Test(expected = IllegalStateException.class)
public void testNoClauses() throws Exception {
Where<Foo, String> where = new Where<Foo, String>(createTableInfo(), null, databaseType);
where.appendSql(null, new StringBuilder(), new ArrayList<ArgumentHolder>());
}
代码示例来源:origin: j256/ormlite-core
@Test
public void testIsNotNull() throws Exception {
Where<Foo, String> where = new Where<Foo, String>(createTableInfo(), null, databaseType);
where.isNotNull(Foo.VAL_COLUMN_NAME);
StringBuilder whereSb = new StringBuilder();
where.appendSql(null, whereSb, new ArrayList<ArgumentHolder>());
StringBuilder sb = new StringBuilder();
databaseType.appendEscapedEntityName(sb, Foo.VAL_COLUMN_NAME);
sb.append(" IS NOT NULL ");
assertEquals(sb.toString(), whereSb.toString());
}
代码示例来源:origin: j256/ormlite-core
@Test(expected = IllegalArgumentException.class)
public void testAndManyZero() throws Exception {
Where<Foo, String> where = new Where<Foo, String>(createTableInfo(), null, databaseType);
where.and(0);
}
代码示例来源:origin: j256/ormlite-core
@Test(expected = IllegalArgumentException.class)
public void testInArrayWithinArray() throws Exception {
Where<Foo, String> where = new Where<Foo, String>(createTableInfo(), null, databaseType);
// NOTE: we can't pass in vals here
where.in(Foo.VAL_COLUMN_NAME, new int[] { 112 });
}
代码示例来源:origin: j256/ormlite-core
@Test(expected = IllegalArgumentException.class)
public void testOrManyZero() throws Exception {
Where<Foo, String> where = new Where<Foo, String>(createTableInfo(), null, databaseType);
where.or(0);
}
代码示例来源:origin: j256/ormlite-core
@Test(expected = IllegalStateException.class)
public void testMissingClause() throws Exception {
Where<Foo, String> where = new Where<Foo, String>(createTableInfo(), null, databaseType);
int val = 1;
where.and();
where.eq(Foo.VAL_COLUMN_NAME, val);
where.appendSql(null, new StringBuilder(), new ArrayList<ArgumentHolder>());
}
代码示例来源:origin: j256/ormlite-core
@Test(expected = IllegalArgumentException.class)
public void testComparisonUnknownField() throws Exception {
Where<Foo, String> where = new Where<Foo, String>(createTableInfo(), null, databaseType);
int val = 1;
where.eq("unknown-field", val);
}
代码示例来源:origin: j256/ormlite-core
@Test(expected = IllegalArgumentException.class)
public void testComparisonFieldNameNotColumnName() throws Exception {
Where<Foo, String> where = new Where<Foo, String>(createTableInfo(), null, databaseType);
assertNotNull(Foo.class.getDeclaredField(Foo.ID_COLUMN_NAME));
int val = 1;
where.eq("stringField", val);
}
代码示例来源:origin: j256/ormlite-core
@Test
public void testGt() throws Exception {
Where<Foo, String> where = new Where<Foo, String>(createTableInfo(), null, databaseType);
int val = 112;
where.gt(Foo.VAL_COLUMN_NAME, val);
testOperation(where, Foo.VAL_COLUMN_NAME, ">", val);
}
代码示例来源:origin: j256/ormlite-core
@Test
public void testNe() throws Exception {
Where<Foo, String> where = new Where<Foo, String>(createTableInfo(), null, databaseType);
int val = 112;
where.ne(Foo.VAL_COLUMN_NAME, val);
testOperation(where, Foo.VAL_COLUMN_NAME, "<>", val);
}
代码示例来源:origin: j256/ormlite-core
@Test
public void testEq() throws Exception {
Where<Foo, String> where = new Where<Foo, String>(createTableInfo(), null, databaseType);
int val = 112;
where.eq(Foo.VAL_COLUMN_NAME, val);
testOperation(where, Foo.VAL_COLUMN_NAME, "=", val);
}
代码示例来源:origin: j256/ormlite-core
@Test
public void testLt() throws Exception {
Where<Foo, String> where = new Where<Foo, String>(createTableInfo(), null, databaseType);
int val = 112;
where.lt(Foo.VAL_COLUMN_NAME, val);
testOperation(where, Foo.VAL_COLUMN_NAME, "<", val);
}
代码示例来源:origin: j256/ormlite-core
@Test
public void testLe() throws Exception {
Where<Foo, String> where = new Where<Foo, String>(createTableInfo(), null, databaseType);
int val = 112;
where.le(Foo.VAL_COLUMN_NAME, val);
testOperation(where, Foo.VAL_COLUMN_NAME, "<=", val);
}
代码示例来源:origin: j256/ormlite-core
@Test
public void testGe() throws Exception {
Where<Foo, String> where = new Where<Foo, String>(createTableInfo(), null, databaseType);
int val = 112;
where.ge(Foo.VAL_COLUMN_NAME, val);
testOperation(where, Foo.VAL_COLUMN_NAME, ">=", val);
}
代码示例来源:origin: j256/ormlite-core
@Test(expected = SQLException.class)
public void testIdEqNoId() throws Exception {
new Where<FooNoId, Integer>(new TableInfo<FooNoId, Integer>(databaseType, FooNoId.class), null, databaseType)
.idEq(100);
}
代码示例来源:origin: j256/ormlite-core
@Test
public void testToString() throws Exception {
Where<Foo, String> where = new Where<Foo, String>(createTableInfo(), null, databaseType);
assertTrue(where.toString().contains("empty where clause"));
String value = "bar";
FieldType numberFieldType = FieldType.createFieldType(databaseType, "foo",
Foo.class.getDeclaredField(Foo.VAL_COLUMN_NAME), Foo.class);
SimpleComparison eq =
new SimpleComparison(Foo.VAL_COLUMN_NAME, numberFieldType, value, SimpleComparison.EQUAL_TO_OPERATION);
where.eq(Foo.VAL_COLUMN_NAME, value);
assertTrue(where.toString().contains(eq.toString()));
}
代码示例来源:origin: j256/ormlite-core
@Test(expected = SQLException.class)
public void testIdEqObjectIdNoId() throws Exception {
new Where<FooNoId, Integer>(new TableInfo<FooNoId, Integer>(databaseType, FooNoId.class), null, databaseType)
.idEq(new BaseDaoImpl<FooNoId, Integer>(connectionSource, FooNoId.class) {
}, new FooNoId());
}
代码示例来源:origin: j256/ormlite-core
@Test(expected = SQLException.class)
public void testInSubQueryToManySubColumns() throws Exception {
TableInfo<ForeignFoo, Integer> tableInfo = new TableInfo<ForeignFoo, Integer>(databaseType, ForeignFoo.class);
Where<ForeignFoo, Integer> where = new Where<ForeignFoo, Integer>(tableInfo, null, databaseType);
BaseDaoImpl<ForeignFoo, Integer> foreignDao =
new BaseDaoImpl<ForeignFoo, Integer>(connectionSource, ForeignFoo.class) {
};
QueryBuilder<ForeignFoo, Integer> qb = foreignDao.queryBuilder();
qb.selectColumns(ID_COLUMN_NAME, FOREIGN_COLUMN_NAME);
where.in(ID_COLUMN_NAME, qb);
}
内容来源于网络,如有侵权,请联系作者删除!