本文整理了Java中com.j256.ormlite.dao.Dao.idExists()
方法的一些代码示例,展示了Dao.idExists()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Dao.idExists()
方法的具体详情如下:
包路径:com.j256.ormlite.dao.Dao
类名称:Dao
方法名:idExists
[英]Returns true if an object exists that matches this ID otherwise false.
[中]如果存在与此ID匹配的对象,则返回true,否则返回false。
代码示例来源:origin: BaronZ88/MinimalistWeather
public void insertOrUpdateWeather(Weather weather) throws SQLException {
TransactionManager.callInTransaction(WeatherDatabaseHelper.getInstance(context).getConnectionSource(), (Callable<Void>) () -> {
if (weatherDaoOperation.idExists(weather.getCityId())) {
updateWeather(weather);
} else {
insertWeather(weather);
}
return null;
});
}
代码示例来源:origin: QuickBlox/q-municate-android
@Override
public boolean exists(ID id) {
try {
return dao.idExists(id);
} catch (SQLException e) {
ErrorUtils.logError(e);
}
return false;
}
代码示例来源:origin: j256/ormlite-core
/**
* @see Dao#idExists(Object)
*/
@Override
public boolean idExists(ID id) {
try {
return dao.idExists(id);
} catch (SQLException e) {
logMessage(e, "idExists threw exception on " + id);
throw new RuntimeException(e);
}
}
代码示例来源:origin: com.j256.ormlite/ormlite-core
/**
* @see Dao#idExists(Object)
*/
@Override
public boolean idExists(ID id) {
try {
return dao.idExists(id);
} catch (SQLException e) {
logMessage(e, "idExists threw exception on " + id);
throw new RuntimeException(e);
}
}
代码示例来源:origin: QuickBlox/q-municate-android
@Override
public boolean exists(long id) {
try {
return dao.idExists(id);
} catch (SQLException e) {
ErrorUtils.logError(e);
}
return false;
}
代码示例来源:origin: j256/ormlite-core
@Test(expected = RuntimeException.class)
public void testIdExists() throws Exception {
@SuppressWarnings("unchecked")
Dao<Foo, String> dao = (Dao<Foo, String>) createMock(Dao.class);
RuntimeExceptionDao<Foo, String> rtDao = new RuntimeExceptionDao<Foo, String>(dao);
String id = "eopwjfpwejf";
expect(dao.idExists(id)).andThrow(new SQLException("Testing catch"));
replay(dao);
rtDao.idExists(id);
verify(dao);
}
}
代码示例来源:origin: j256/ormlite-core
@Test
public void testIfExists() throws Exception {
Dao<Foo, Integer> dao = createDao(Foo.class, true);
Foo foo = new Foo();
assertFalse(dao.idExists(1));
assertEquals(1, dao.create(foo));
assertTrue(dao.idExists(1));
assertFalse(dao.idExists(2));
}
内容来源于网络,如有侵权,请联系作者删除!