本文整理汇总了Java中com.j256.ormlite.stmt.PreparedDelete类的典型用法代码示例。如果您正苦于以下问题:Java PreparedDelete类的具体用法?Java PreparedDelete怎么用?Java PreparedDelete使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PreparedDelete类属于com.j256.ormlite.stmt包,在下文中一共展示了PreparedDelete类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateWeather
import com.j256.ormlite.stmt.PreparedDelete; //导入依赖的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());
}
示例2: delete
import com.j256.ormlite.stmt.PreparedDelete; //导入依赖的package包/类
/**
* Delete by tile matrix set name
*
* @param tileMatrixSetName
* tile matrix set name
* @return deleted count
*/
public int delete(String tileMatrixSetName) {
DeleteBuilder<GriddedCoverage, Long> db = deleteBuilder();
int deleted = 0;
try {
db.where().eq(GriddedCoverage.COLUMN_TILE_MATRIX_SET_NAME,
tileMatrixSetName);
PreparedDelete<GriddedCoverage> deleteQuery = db.prepare();
deleted = delete(deleteQuery);
} catch (SQLException e) {
throw new GeoPackageException(
"Failed to delete Gridded Coverage by Tile Matrix Set Name: "
+ tileMatrixSetName, e);
}
return deleted;
}
示例3: delete
import com.j256.ormlite.stmt.PreparedDelete; //导入依赖的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;
}
示例4: delete
import com.j256.ormlite.stmt.PreparedDelete; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public int delete(FeatureTileLink data) throws SQLException {
DeleteBuilder<FeatureTileLink, FeatureTileLinkKey> db = deleteBuilder();
db.where()
.eq(FeatureTileLink.COLUMN_FEATURE_TABLE_NAME,
data.getFeatureTableName())
.and()
.eq(FeatureTileLink.COLUMN_TILE_TABLE_NAME,
data.getTileTableName());
PreparedDelete<FeatureTileLink> deleteQuery = db.prepare();
int deleted = delete(deleteQuery);
return deleted;
}
示例5: deleteCascade
import com.j256.ormlite.stmt.PreparedDelete; //导入依赖的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;
}
示例6: clearGeometryIndices
import com.j256.ormlite.stmt.PreparedDelete; //导入依赖的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;
}
示例7: delete
import com.j256.ormlite.stmt.PreparedDelete; //导入依赖的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;
}
示例8: updateOrCreateUserTechnologies
import com.j256.ormlite.stmt.PreparedDelete; //导入依赖的package包/类
/**
* remove existing technologies and reattach new ones
* @param user
* @throws SQLException
*/
@Override
public void updateOrCreateUserTechnologies(User user) throws SQLException {
// clear technologies attached to user
Where<Technology, Integer> where = deleteBuilder().where();
where = where.eq("user_id", user.getId());
PreparedDelete<Technology> preparedDelete =
(PreparedDelete<Technology>) where.prepare();
delete(preparedDelete);
// create technologies
for (Technology technology : user.getOtherTechnologies()) {
create(technology);
}
create(user.getPrimaryTechnology());
}
示例9: rxDelete
import com.j256.ormlite.stmt.PreparedDelete; //导入依赖的package包/类
@Override
public Observable<Integer> rxDelete(final PreparedDelete<DataType> preparedDelete) {
final Func0<Observable<Integer>> loFunc = () -> {
try {
return Observable.just(delete(preparedDelete));
} catch (SQLException e) {
return Observable.error(e);
}
};
return Observable.defer(loFunc);
}
示例10: deleteAll
import com.j256.ormlite.stmt.PreparedDelete; //导入依赖的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;
}
示例11: deleteByTableName
import com.j256.ormlite.stmt.PreparedDelete; //导入依赖的package包/类
/**
* Delete by table name, either feature or tile table name
*
* @param tableName
* table name, feature or tile
* @return rows deleted
* @throws SQLException
*/
public int deleteByTableName(String tableName) throws SQLException {
DeleteBuilder<FeatureTileLink, FeatureTileLinkKey> db = deleteBuilder();
db.where().eq(FeatureTileLink.COLUMN_FEATURE_TABLE_NAME, tableName)
.or().eq(FeatureTileLink.COLUMN_TILE_TABLE_NAME, tableName);
PreparedDelete<FeatureTileLink> deleteQuery = db.prepare();
int deleted = delete(deleteQuery);
return deleted;
}
示例12: deleteAll
import com.j256.ormlite.stmt.PreparedDelete; //导入依赖的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;
}
示例13: delete
import com.j256.ormlite.stmt.PreparedDelete; //导入依赖的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;
}
示例14: deleteAll
import com.j256.ormlite.stmt.PreparedDelete; //导入依赖的package包/类
/**
* Delete all geometry indices
*
* @return rows deleted
* @throws SQLException
* @since 1.1.5
*/
public int deleteAll() throws SQLException {
int count = 0;
if (isTableExists()) {
DeleteBuilder<GeometryIndex, GeometryIndexKey> db = deleteBuilder();
PreparedDelete<GeometryIndex> deleteQuery = db.prepare();
count = delete(deleteQuery);
}
return count;
}
示例15: deleteAll
import com.j256.ormlite.stmt.PreparedDelete; //导入依赖的package包/类
/**
* Delete all table indices
*
* @return rows deleted
* @throws SQLException
* @since 1.1.5
*/
public int deleteAll() throws SQLException {
int count = 0;
if (isTableExists()) {
DeleteBuilder<TableIndex, String> db = deleteBuilder();
PreparedDelete<TableIndex> deleteQuery = db.prepare();
count = delete(deleteQuery);
}
return count;
}