當前位置: 首頁>>代碼示例>>Java>>正文


Java DeleteBuilder.prepare方法代碼示例

本文整理匯總了Java中com.j256.ormlite.stmt.DeleteBuilder.prepare方法的典型用法代碼示例。如果您正苦於以下問題:Java DeleteBuilder.prepare方法的具體用法?Java DeleteBuilder.prepare怎麽用?Java DeleteBuilder.prepare使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.j256.ormlite.stmt.DeleteBuilder的用法示例。


在下文中一共展示了DeleteBuilder.prepare方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: 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());
    }
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:27,代碼來源:WeatherDao.java

示例2: delete

import com.j256.ormlite.stmt.DeleteBuilder; //導入方法依賴的package包/類
/**
 * Delete by table name
 * 
 * @param tableName
 *            table name
 * @return deleted count
 */
public int delete(String tableName) {
	DeleteBuilder<GriddedTile, Long> db = deleteBuilder();

	int deleted = 0;

	try {
		db.where().eq(GriddedTile.COLUMN_TABLE_NAME, tableName);

		PreparedDelete<GriddedTile> deleteQuery = db.prepare();
		deleted = delete(deleteQuery);
	} catch (SQLException e) {
		throw new GeoPackageException(
				"Failed to delete Gridded Tile by Table Name: " + tableName,
				e);
	}

	return deleted;
}
 
開發者ID:ngageoint,項目名稱:geopackage-core-java,代碼行數:26,代碼來源:GriddedTileDao.java

示例3: deleteCascade

import com.j256.ormlite.stmt.DeleteBuilder; //導入方法依賴的package包/類
/**
 * Delete the TableIndex, cascading
 * 
 * @param tableIndex
 * @return rows deleted
 * @throws SQLException
 */
public int deleteCascade(TableIndex tableIndex) throws SQLException {
	int count = 0;

	if (tableIndex != null) {

		// Delete Geometry Indices
		GeometryIndexDao geometryIndexDao = getGeometryIndexDao();
		if (geometryIndexDao.isTableExists()) {
			DeleteBuilder<GeometryIndex, GeometryIndexKey> db = geometryIndexDao
					.deleteBuilder();
			db.where().eq(GeometryIndex.COLUMN_TABLE_NAME,
					tableIndex.getTableName());
			PreparedDelete<GeometryIndex> deleteQuery = db.prepare();
			geometryIndexDao.delete(deleteQuery);
		}

		count = delete(tableIndex);
	}
	return count;
}
 
開發者ID:ngageoint,項目名稱:geopackage-core-java,代碼行數:28,代碼來源:TableIndexDao.java

示例4: clearGeometryIndices

import com.j256.ormlite.stmt.DeleteBuilder; //導入方法依賴的package包/類
/**
 * Clear the Geometry Indices for the table name
 * 
 * @return number of rows deleted
 */
private int clearGeometryIndices() {
	int deleted = 0;
	DeleteBuilder<GeometryIndex, GeometryIndexKey> db = geometryIndexDao
			.deleteBuilder();
	try {
		db.where().eq(GeometryIndex.COLUMN_TABLE_NAME, tableName);
		PreparedDelete<GeometryIndex> deleteQuery = db.prepare();
		deleted = geometryIndexDao.delete(deleteQuery);
	} catch (SQLException e) {
		throw new GeoPackageException(
				"Failed to clear Geometry Index rows for GeoPackage: "
						+ geoPackage.getName() + ", Table Name: "
						+ tableName + ", Column Name: " + columnName, e);
	}

	return deleted;
}
 
開發者ID:ngageoint,項目名稱:geopackage-core-java,代碼行數:23,代碼來源:FeatureTableCoreIndex.java

示例5: delete

import com.j256.ormlite.stmt.DeleteBuilder; //導入方法依賴的package包/類
/**
 * {@inheritDoc}
 */
@Override
public int delete(GeometryColumnsSfSql data) throws SQLException {
	DeleteBuilder<GeometryColumnsSfSql, TableColumnKey> db = deleteBuilder();

	db.where()
			.eq(GeometryColumnsSfSql.COLUMN_F_TABLE_NAME,
					data.getFTableName())
			.and()
			.eq(GeometryColumnsSfSql.COLUMN_F_GEOMETRY_COLUMN,
					data.getFGeometryColumn());

	PreparedDelete<GeometryColumnsSfSql> deleteQuery = db.prepare();
	int deleted = delete(deleteQuery);
	return deleted;
}
 
開發者ID:ngageoint,項目名稱:geopackage-core-java,代碼行數:19,代碼來源:GeometryColumnsSfSqlDao.java

示例6: delete

import com.j256.ormlite.stmt.DeleteBuilder; //導入方法依賴的package包/類
/**
 * {@inheritDoc}
 */
@Override
public int delete(DataColumns data) throws SQLException {
	DeleteBuilder<DataColumns, TableColumnKey> db = deleteBuilder();

	db.where().eq(DataColumns.COLUMN_TABLE_NAME, data.getTableName()).and()
			.eq(DataColumns.COLUMN_COLUMN_NAME, data.getColumnName());

	PreparedDelete<DataColumns> deleteQuery = db.prepare();
	int deleted = delete(deleteQuery);
	return deleted;
}
 
開發者ID:ngageoint,項目名稱:geopackage-core-java,代碼行數:15,代碼來源:DataColumnsDao.java

示例7: delete

import com.j256.ormlite.stmt.DeleteBuilder; //導入方法依賴的package包/類
/**
 * {@inheritDoc}
 */
@Override
public int delete(GeometryColumnsSqlMm data) throws SQLException {
	DeleteBuilder<GeometryColumnsSqlMm, TableColumnKey> db = deleteBuilder();

	db.where()
			.eq(GeometryColumnsSqlMm.COLUMN_TABLE_NAME, data.getTableName())
			.and()
			.eq(GeometryColumnsSqlMm.COLUMN_COLUMN_NAME,
					data.getColumnName());

	PreparedDelete<GeometryColumnsSqlMm> deleteQuery = db.prepare();
	int deleted = delete(deleteQuery);
	return deleted;
}
 
開發者ID:ngageoint,項目名稱:geopackage-core-java,代碼行數:18,代碼來源:GeometryColumnsSqlMmDao.java

示例8: deleteAll

import com.j256.ormlite.stmt.DeleteBuilder; //導入方法依賴的package包/類
private static <E extends Entity> long deleteAll(final Dao<E, ?> dao, final DeleteBuilder<E, ?> deleteBuilder) throws SQLException {
	final PreparedDelete<E> preparedDelete = deleteBuilder.prepare();
	if (LOGGER.isDebugEnabled()) {
		LOGGER.debug("deleteAll: " + ReflectionToStringBuilder.toString(dao) + ", " + preparedDelete);
	}
	final long result = dao.delete(preparedDelete);
	if (LOGGER.isDebugEnabled()) {
		LOGGER.debug("deleteAll: " + result);
	}
	return result;
}
 
開發者ID:t3t5u,項目名稱:common-ormlite,代碼行數:12,代碼來源:AbstractDao.java

示例9: delete

import com.j256.ormlite.stmt.DeleteBuilder; //導入方法依賴的package包/類
/**
 * {@inheritDoc}
 */
@Override
public int delete(TileMatrix data) throws SQLException {
	DeleteBuilder<TileMatrix, TileMatrixKey> db = deleteBuilder();

	db.where().eq(TileMatrix.COLUMN_TABLE_NAME, data.getTableName()).and()
			.eq(TileMatrix.COLUMN_ZOOM_LEVEL, data.getZoomLevel());

	PreparedDelete<TileMatrix> deleteQuery = db.prepare();
	int deleted = delete(deleteQuery);
	return deleted;
}
 
開發者ID:ngageoint,項目名稱:geopackage-core-java,代碼行數:15,代碼來源:TileMatrixDao.java

示例10: deleteAll

import com.j256.ormlite.stmt.DeleteBuilder; //導入方法依賴的package包/類
/**
 * Delete all feature tile links
 * 
 * @return rows deleted
 * @throws SQLException
 * @since 1.1.5
 */
public int deleteAll() throws SQLException {

	int count = 0;

	if (isTableExists()) {
		DeleteBuilder<FeatureTileLink, FeatureTileLinkKey> db = deleteBuilder();
		PreparedDelete<FeatureTileLink> deleteQuery = db.prepare();
		count = delete(deleteQuery);
	}

	return count;
}
 
開發者ID:ngageoint,項目名稱:geopackage-core-java,代碼行數:20,代碼來源:FeatureTileLinkDao.java

示例11: delete

import com.j256.ormlite.stmt.DeleteBuilder; //導入方法依賴的package包/類
/**
 * {@inheritDoc}
 */
@Override
public int delete(GeometryIndex data) throws SQLException {
	DeleteBuilder<GeometryIndex, GeometryIndexKey> db = deleteBuilder();

	db.where().eq(GeometryIndex.COLUMN_TABLE_NAME, data.getTableName())
			.and().eq(GeometryIndex.COLUMN_GEOM_ID, data.getGeomId());

	PreparedDelete<GeometryIndex> deleteQuery = db.prepare();
	int deleted = delete(deleteQuery);
	return deleted;
}
 
開發者ID:ngageoint,項目名稱:geopackage-core-java,代碼行數:15,代碼來源:GeometryIndexDao.java

示例12: deleteUserByExternalId

import com.j256.ormlite.stmt.DeleteBuilder; //導入方法依賴的package包/類
@Override
public void deleteUserByExternalId(String externalId) {
    try {
        DeleteBuilder<QMUser, Long> deleteBuilder = dao.deleteBuilder();
        deleteBuilder.where().eq(EXTERNAL_ID,externalId);
        PreparedDelete<QMUser> preparedQuery = deleteBuilder.prepare();
        dao.delete(preparedQuery);
        notifyObservers(OBSERVE_KEY);
    } catch (SQLException e) {
        ErrorUtils.logError(e);
    }
}
 
開發者ID:QuickBlox,項目名稱:q-municate-android,代碼行數:13,代碼來源:QMUserCacheImpl.java

示例13: testDelete

import com.j256.ormlite.stmt.DeleteBuilder; //導入方法依賴的package包/類
/**
 * Test delete
 * 
 * @param geoPackage
 * @throws SQLException
 */
public static void testDelete(GeoPackage geoPackage) throws SQLException {

	ExtensionsDao dao = geoPackage.getExtensionsDao();

	if (dao.isTableExists()) {
		List<Extensions> results = dao.queryForAll();

		if (!results.isEmpty()) {

			// Choose random metadata
			int random = (int) (Math.random() * results.size());
			Extensions extensions = results.get(random);

			// Delete the extensions
			dao.delete(extensions);

			// Verify deleted
			Extensions queryExtensions = dao.queryByExtension(
					extensions.getExtensionName(),
					extensions.getTableName(), extensions.getColumnName());
			TestCase.assertNull(queryExtensions);

			// Choose prepared deleted
			results = dao.queryForAll();
			if (!results.isEmpty()) {

				// Choose random metadata
				random = (int) (Math.random() * results.size());
				extensions = results.get(random);

				// Find which metadata to delete
				QueryBuilder<Extensions, Void> qb = dao.queryBuilder();
				qb.where().eq(Extensions.COLUMN_EXTENSION_NAME,
						extensions.getExtensionName());
				PreparedQuery<Extensions> query = qb.prepare();
				List<Extensions> queryResults = dao.query(query);
				int count = queryResults.size();

				// Delete
				DeleteBuilder<Extensions, Void> db = dao.deleteBuilder();
				db.where().eq(Extensions.COLUMN_EXTENSION_NAME,
						extensions.getExtensionName());
				PreparedDelete<Extensions> deleteQuery = db.prepare();
				int deleted = dao.delete(deleteQuery);

				TestCase.assertEquals(count, deleted);

			}
		}
	}
}
 
開發者ID:ngageoint,項目名稱:geopackage-android,代碼行數:58,代碼來源:ExtensionsUtils.java

示例14: testDelete

import com.j256.ormlite.stmt.DeleteBuilder; //導入方法依賴的package包/類
/**
 * Test delete
 * 
 * @param geoPackage
 * @throws SQLException
 */
public static void testDelete(GeoPackage geoPackage) throws SQLException {

	GeometryColumnsDao dao = geoPackage.getGeometryColumnsDao();

	if (dao.isTableExists()) {
		List<GeometryColumns> results = dao.queryForAll();

		if (!results.isEmpty()) {

			// Choose random geometry columns
			int random = (int) (Math.random() * results.size());
			GeometryColumns geometryColumns = results.get(random);

			// Delete the geometry columns
			dao.delete(geometryColumns);

			// Verify deleted
			GeometryColumns queryGeometryColumns = dao
					.queryForId(geometryColumns.getId());
			TestCase.assertNull(queryGeometryColumns);

			// Prepared deleted
			results = dao.queryForAll();
			if (!results.isEmpty()) {

				// Choose random geometry columns
				random = (int) (Math.random() * results.size());
				geometryColumns = results.get(random);

				// Find which geometry columns to delete
				QueryBuilder<GeometryColumns, TableColumnKey> qb = dao
						.queryBuilder();
				qb.where().eq(GeometryColumns.COLUMN_GEOMETRY_TYPE_NAME,
						geometryColumns.getGeometryType().getName());
				PreparedQuery<GeometryColumns> query = qb.prepare();
				List<GeometryColumns> queryResults = dao.query(query);
				int count = queryResults.size();

				// Delete
				DeleteBuilder<GeometryColumns, TableColumnKey> db = dao
						.deleteBuilder();
				db.where().eq(GeometryColumns.COLUMN_GEOMETRY_TYPE_NAME,
						geometryColumns.getGeometryType().getName());
				PreparedDelete<GeometryColumns> deleteQuery = db.prepare();
				int deleted = dao.delete(deleteQuery);

				TestCase.assertEquals(count, deleted);

			}
		}
	}
}
 
開發者ID:ngageoint,項目名稱:geopackage-android,代碼行數:59,代碼來源:GeometryColumnsUtils.java

示例15: testDelete

import com.j256.ormlite.stmt.DeleteBuilder; //導入方法依賴的package包/類
/**
 * Test delete
 * 
 * @param geoPackage
 * @throws SQLException
 */
public static void testDelete(GeoPackage geoPackage) throws SQLException {

	MetadataReferenceDao dao = geoPackage.getMetadataReferenceDao();

	if (dao.isTableExists()) {
		List<MetadataReference> results = dao.queryForAll();

		if (!results.isEmpty()) {

			// Choose random metadata
			int random = (int) (Math.random() * results.size());
			MetadataReference metadataReference = results.get(random);

			// Delete the metadata reference
			dao.delete(metadataReference);

			// Verify deleted
			List<MetadataReference> queryMetadataReferenceList = dao
					.queryByMetadata(metadataReference.getFileId(),
							metadataReference.getParentId());
			TestCase.assertTrue(queryMetadataReferenceList.isEmpty());

			// Choose prepared deleted
			results = dao.queryForAll();
			if (!results.isEmpty()) {

				// Choose random metadata
				random = (int) (Math.random() * results.size());
				metadataReference = results.get(random);

				// Find which metadata to delete
				QueryBuilder<MetadataReference, Void> qb = dao
						.queryBuilder();
				qb.where().eq(MetadataReference.COLUMN_FILE_ID,
						metadataReference.getFileId());
				PreparedQuery<MetadataReference> query = qb.prepare();
				List<MetadataReference> queryResults = dao.query(query);
				int count = queryResults.size();

				// Delete
				DeleteBuilder<MetadataReference, Void> db = dao
						.deleteBuilder();
				db.where().eq(MetadataReference.COLUMN_FILE_ID,
						metadataReference.getFileId());
				PreparedDelete<MetadataReference> deleteQuery = db
						.prepare();
				int deleted = dao.delete(deleteQuery);

				TestCase.assertEquals(count, deleted);

			}
		}
	}
}
 
開發者ID:ngageoint,項目名稱:geopackage-android,代碼行數:61,代碼來源:MetadataReferenceUtils.java


注:本文中的com.j256.ormlite.stmt.DeleteBuilder.prepare方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。