本文整理匯總了Java中com.j256.ormlite.stmt.DeleteBuilder類的典型用法代碼示例。如果您正苦於以下問題:Java DeleteBuilder類的具體用法?Java DeleteBuilder怎麽用?Java DeleteBuilder使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
DeleteBuilder類屬於com.j256.ormlite.stmt包,在下文中一共展示了DeleteBuilder類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: deleteByIds
import com.j256.ormlite.stmt.DeleteBuilder; //導入依賴的package包/類
public static void deleteByIds(final List<Long> ids, final DatabaseCallback<Void> callback) {
DatabaseHelper.getInstance().execute(new Runnable() {
@Override
public void run() {
final RuntimeExceptionDao<MyFace, Long> dao = DatabaseHelper.getInstance().getCachedRuntimeExceptionDao(MyFace.class);
DeleteBuilder<MyFace, Long> db = dao.deleteBuilder();
try {
db.where().in("id", ids);
db.delete();
callback.onCompleted(0, null);
} catch (Exception e) {
e.printStackTrace();
callback.onCompleted(1, null);
}
}
});
}
示例2: deleteByPhotosSync
import com.j256.ormlite.stmt.DeleteBuilder; //導入依賴的package包/類
private static void deleteByPhotosSync(final List<Long> photoIds) {
final RuntimeExceptionDao<MyFacePhoto, Long> dao = DatabaseHelper.getInstance().getCachedRuntimeExceptionDao(MyFacePhoto.class);
dao.callBatchTasks(new Callable() {
@Override
public Object call() throws Exception {
try {
DeleteBuilder<MyFacePhoto, Long> builder = dao.deleteBuilder();
builder.where().in("photo_id", photoIds);
builder.delete();
} catch (Exception e) {
Log.w(TAG, e.getMessage());
}
return null;
}
});
}
示例3: deleteByPhotosSync
import com.j256.ormlite.stmt.DeleteBuilder; //導入依賴的package包/類
private static void deleteByPhotosSync(final List<Long> photoIds) {
final RuntimeExceptionDao<MyMomentPhoto, Long> dao = DatabaseHelper.getInstance().getCachedRuntimeExceptionDao(MyMomentPhoto.class);
dao.callBatchTasks(new Callable() {
@Override
public Object call() throws Exception {
try {
DeleteBuilder<MyMomentPhoto, Long> builder = dao.deleteBuilder();
builder.where().in("photoId", photoIds);
builder.delete();
} catch (Exception e) {
Log.w(TAG, e.getMessage());
}
return null;
}
});
}
示例4: deleteByPhotosSync
import com.j256.ormlite.stmt.DeleteBuilder; //導入依賴的package包/類
private static void deleteByPhotosSync(final List<Long> photoIds) {
final RuntimeExceptionDao<MyTagPhoto, Long> dao = DatabaseHelper.getInstance().getCachedRuntimeExceptionDao(MyTagPhoto.class);
dao.callBatchTasks(new Callable() {
@Override
public Object call() throws Exception {
try {
DeleteBuilder<MyTagPhoto, Long> builder = dao.deleteBuilder();
builder.where().in("photo_id", photoIds);
builder.delete();
} catch (Exception e) {
Log.w(TAG, e.getMessage());
}
return null;
}
});
}
示例5: deleteByIds
import com.j256.ormlite.stmt.DeleteBuilder; //導入依賴的package包/類
public static void deleteByIds(final List<Long> ids, final DatabaseCallback<Void> callback) {
DatabaseHelper.getInstance().execute(new Runnable() {
@Override
public void run() {
final RuntimeExceptionDao<MyAlbum, Long> dao = DatabaseHelper.getInstance().getCachedRuntimeExceptionDao(MyAlbum.class);
DeleteBuilder<MyAlbum, Long> db = dao.deleteBuilder();
try {
db.where().in("id", ids);
db.delete();
callback.onCompleted(0, null);
} catch (Exception e) {
e.printStackTrace();
callback.onCompleted(1, null);
}
}
});
}
示例6: deleteByIds
import com.j256.ormlite.stmt.DeleteBuilder; //導入依賴的package包/類
public static void deleteByIds(final List<Long> ids, final DatabaseCallback<Void> callback) {
DatabaseHelper.getInstance().execute(new Runnable() {
@Override
public void run() {
final RuntimeExceptionDao<MyPhoto, Long> dao = DatabaseHelper.getInstance().getCachedRuntimeExceptionDao(MyPhoto.class);
DeleteBuilder<MyPhoto, Long> db = dao.deleteBuilder();
try {
db.where().in("id", ids);
db.delete();
callback.onCompleted(0, null);
} catch (Exception e) {
e.printStackTrace();
callback.onCompleted(1, null);
}
}
});
}
示例7: deleteByPhotosSync
import com.j256.ormlite.stmt.DeleteBuilder; //導入依賴的package包/類
private static void deleteByPhotosSync(final List<Long> photoIds) {
final RuntimeExceptionDao<MyAlbumPhoto, Long> dao = DatabaseHelper.getInstance().getCachedRuntimeExceptionDao(MyAlbumPhoto.class);
dao.callBatchTasks(new Callable() {
@Override
public Object call() throws Exception {
try {
DeleteBuilder<MyAlbumPhoto, Long> builder = dao.deleteBuilder();
builder.where().in("photoId", photoIds);
builder.delete();
} catch (Exception e) {
Log.w(TAG, e.getMessage());
}
return null;
}
});
}
示例8: updateWeather
import com.j256.ormlite.stmt.DeleteBuilder; //導入依賴的package包/類
private void updateWeather(Weather weather) throws SQLException {
weatherDaoOperation.update(weather);
apiDaoOperation.update(weather.getAirQualityLive());
//先刪除舊數據
DeleteBuilder<WeatherForecast, Long> forecastDeleteBuilder = forecastDaoOperation.deleteBuilder();
forecastDeleteBuilder.where().eq(WeatherForecast.CITY_ID_FIELD_NAME, weather.getCityId());
PreparedDelete<WeatherForecast> forecastPrepared = forecastDeleteBuilder.prepare();
forecastDaoOperation.delete(forecastPrepared);
//再插入新數據
for (WeatherForecast weatherForecast : weather.getWeatherForecasts()) {
forecastDaoOperation.create(weatherForecast);
}
//先刪除舊數據
DeleteBuilder<LifeIndex, Long> lifeIndexDeleteBuilder = lifeIndexesDaoOperation.deleteBuilder();
lifeIndexDeleteBuilder.where().eq(LifeIndex.CITY_ID_FIELD_NAME, weather.getCityId());
PreparedDelete<LifeIndex> lifeIndexPrepared = lifeIndexDeleteBuilder.prepare();
lifeIndexesDaoOperation.delete(lifeIndexPrepared);
//再插入新數據
for (LifeIndex index : weather.getLifeIndexes()) {
lifeIndexesDaoOperation.create(index);
}
realTimeDaoOperation.update(weather.getWeatherLive());
}
示例9: deleteAll
import com.j256.ormlite.stmt.DeleteBuilder; //導入依賴的package包/類
@Override
public int deleteAll()
{
try
{
DeleteBuilder<FocusItemInfo, Long> deleteBuilder = mFocusItemInfoDao.deleteBuilder();
deleteBuilder.where().isNotNull("id");
return deleteBuilder.delete();
}
catch (SQLException e)
{
e.printStackTrace();
}
return super.deleteAll();
}
示例10: deleteAll
import com.j256.ormlite.stmt.DeleteBuilder; //導入依賴的package包/類
@Override
public int deleteAll()
{
try
{
DeleteBuilder<MyFavorites, Long> deleteBuilder = mMyFavoritesDao.deleteBuilder();
deleteBuilder.where().isNotNull("albumid");
return deleteBuilder.delete();
}
catch (SQLException e)
{
e.printStackTrace();
}
return super.deleteAll();
}
示例11: deleteByAlbumid
import com.j256.ormlite.stmt.DeleteBuilder; //導入依賴的package包/類
/**
*
* @param albumid
* @return
*/
public int deleteByAlbumid(String albumid)
{
try
{
DeleteBuilder<PhotoInfo, Long> deleteBuilder = mPhotoDao.deleteBuilder();
deleteBuilder.where().eq("albumid", albumid);
return deleteBuilder.delete();
}
catch (SQLException e)
{
e.printStackTrace();
}
return super.deleteAll();
}
示例12: deleteAll
import com.j256.ormlite.stmt.DeleteBuilder; //導入依賴的package包/類
@Override
public int deleteAll()
{
try
{
DeleteBuilder<AlbumInfo, Long> deleteBuilder = mAlbumDao.deleteBuilder();
deleteBuilder.where().isNotNull("albumid");
return deleteBuilder.delete();
}
catch (SQLException e)
{
e.printStackTrace();
}
return super.deleteAll();
}
示例13: onUpgrade
import com.j256.ormlite.stmt.DeleteBuilder; //導入依賴的package包/類
/**
* This is called when your application is upgraded and it has a higher version number. This allows you to adjust
* the various data to match the new version number.
*/
@Override
public void onUpgrade(SQLiteDatabase db, ConnectionSource connectionSource, int oldVersion, int newVersion) {
try {
Log.i(TAG, "onUpgrade");
TableUtils.dropTable(connectionSource, SuspectedApp.class, true);
Log.d(TAG, String.format("Dropped suspected app table!"));
Dao<WhiteEntry, Integer> whiteListDao = getWhiteListDao();
DeleteBuilder<WhiteEntry, Integer> deleteBuilder = whiteListDao.deleteBuilder();
deleteBuilder.where().eq("systemEntry", Boolean.TRUE);
int deleted = deleteBuilder.delete();
Log.d(TAG, String.format("Delete %d old system whitelist entries", deleted));
onCreate(db, connectionSource);
} catch (SQLException e) {
Log.e(TAG, "Can't drop databases", e);
throw new RuntimeException(e);
}
}
示例14: saveEventGuestOutfitsToDb
import com.j256.ormlite.stmt.DeleteBuilder; //導入依賴的package包/類
private void saveEventGuestOutfitsToDb(Set<EventGuestOutfit> eventGuestOutfits, Set<EventGuestOutfitItem> eventGuestOutfitItems) throws SQLException {
for(EventGuestOutfit eventGuestOutfit : eventGuestOutfits) {
Log.i(TAG, "Saving " + eventGuestOutfit.getClass().getSimpleName() + " uuid: " + eventGuestOutfit.getUuid());
// Save outfit
mHelper.getEventGuestOutfitDao().createOrUpdate(eventGuestOutfit);
// Delete existing outfit items
DeleteBuilder<EventGuestOutfitItem, String> deleteBuilder = mHelper.getEventGuestOutfitItemDao().deleteBuilder();
deleteBuilder.where().eq("event_guest_outfit_uuid", eventGuestOutfit.getUuid());
deleteBuilder.delete();
// Create new outfit items
for(EventGuestOutfitItem eventGuestOutfitItem : eventGuestOutfitItems) {
if(eventGuestOutfit.getUuid().equals(eventGuestOutfitItem.getEventGuestOutfit().getUuid())) {
mHelper.getItemDao().createIfNotExists(eventGuestOutfitItem.getItem());
mHelper.getEventGuestOutfitItemDao().create(eventGuestOutfitItem);
}
}
}
}
示例15: storeFeed
import com.j256.ormlite.stmt.DeleteBuilder; //導入依賴的package包/類
private void storeFeed(FeedUserRequest request, TopicsListResponse response,
int feedType, String query) throws SQLException {
DebugTimer.startInterval("saving topic feed");
if (TextUtils.isEmpty(request.getCursor())) {
DeleteBuilder<TopicFeedRelation, Integer> deleteBuilder = feedDao.deleteBuilder();
String userHandleQuery = (query != null) ? query : TopicFeedRelation.DEFAULT_QUERY;
deleteBuilder.where()
.eq(DbSchemas.TopicFeedRelation.FEED_TYPE, feedType)
.and().eq(DbSchemas.TopicFeedRelation.QUERY, userHandleQuery);
deleteBuilder.delete();
}
DbTransaction.performTransaction(
topicDao,
() -> insertTopicFeedContents(response.getData(), feedType, query)
);
DebugTimer.endInterval();
DebugLog.i("stored " + response.getData().size() + " topics for " + request);
}