本文整理了Java中com.j256.ormlite.dao.Dao.queryForMatchingArgs()
方法的一些代码示例,展示了Dao.queryForMatchingArgs()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Dao.queryForMatchingArgs()
方法的具体详情如下:
包路径:com.j256.ormlite.dao.Dao
类名称:Dao
方法名:queryForMatchingArgs
[英]Same as #queryForMatching(Object) but this uses SelectArg and SQL ? arguments. This is slightly more expensive but you don't have to worry about SQL quote escaping.
[中]与#queryForMatching(Object)相同,但它使用SelectArg和SQL?论据。这稍微贵一点,但您不必担心SQL引号转义。
代码示例来源:origin: com.j256.ormlite/ormlite-core
/**
* @see Dao#queryForMatchingArgs(Object)
*/
@Override
public List<T> queryForMatchingArgs(T matchObj) {
try {
return dao.queryForMatchingArgs(matchObj);
} catch (SQLException e) {
logMessage(e, "queryForMatchingArgs threw exception on: " + matchObj);
throw new RuntimeException(e);
}
}
代码示例来源:origin: j256/ormlite-core
/**
* @see Dao#queryForMatchingArgs(Object)
*/
@Override
public List<T> queryForMatchingArgs(T matchObj) {
try {
return dao.queryForMatchingArgs(matchObj);
} catch (SQLException e) {
logMessage(e, "queryForMatchingArgs threw exception on: " + matchObj);
throw new RuntimeException(e);
}
}
代码示例来源:origin: kamax-matrix/mxisd
@Override
public Optional<IThreePidSessionDao> findThreePidSession(ThreePid tpid, String secret) {
return withCatcher(() -> {
List<ThreePidSessionDao> daoList = sessionDao.queryForMatchingArgs(new ThreePidSessionDao(tpid, secret));
if (daoList.size() > 1) {
throw new InternalServerError("Lookup for 3PID Session " +
tpid + " returned more than one result");
}
if (daoList.isEmpty()) {
return Optional.empty();
}
return Optional.of(daoList.get(0));
});
}
代码示例来源:origin: kamax-matrix/mxisd
@Override
public Optional<ASTransactionDao> getTransactionResult(String localpart, String txnId) {
return withCatcher(() -> {
ASTransactionDao dao = new ASTransactionDao();
dao.setLocalpart(localpart);
dao.setTransactionId(txnId);
List<ASTransactionDao> daoList = asTxnDao.queryForMatchingArgs(dao);
if (daoList.size() > 1) {
throw new InternalServerError("Lookup for Transaction " +
txnId + " for localpart " + localpart + " returned more than one result");
}
if (daoList.isEmpty()) {
return Optional.empty();
}
return Optional.of(daoList.get(0));
});
}
代码示例来源:origin: j256/ormlite-core
@Test(expected = RuntimeException.class)
public void testQueryForMatchingArgsThrow() throws Exception {
@SuppressWarnings("unchecked")
Dao<Foo, String> dao = (Dao<Foo, String>) createMock(Dao.class);
RuntimeExceptionDao<Foo, String> rtDao = new RuntimeExceptionDao<Foo, String>(dao);
expect(dao.queryForMatchingArgs(null)).andThrow(new SQLException("Testing catch"));
replay(dao);
rtDao.queryForMatchingArgs(null);
verify(dao);
}
代码示例来源:origin: j256/ormlite-core
@Test
public void testQueryForMatchingArgs() throws Exception {
Dao<Foo, Integer> dao = createDao(Foo.class, true);
assertEquals(0, dao.countOf());
Foo foo1 = new Foo();
int val = 1231231;
foo1.val = val;
assertEquals(1, dao.create(foo1));
Foo foo2 = new Foo();
foo2.val = val + 1;
assertEquals(1, dao.create(foo2));
Foo match = new Foo();
match.stringField = "this id has a quote '";
List<Foo> results = dao.queryForMatchingArgs(match);
assertEquals(0, results.size());
}
代码示例来源:origin: j256/ormlite-core
assertTrue(dao.objectsEqual(foo, list.get(0)));
list = dao.queryForMatchingArgs(foo);
assertEquals(1, list.size());
assertTrue(dao.objectsEqual(foo, list.get(0)));
内容来源于网络,如有侵权,请联系作者删除!