@Override public Feature buildFeature( ResultSet rs ) throws SQLException { Feature feature = null; try { String gmlId = rs.getString( 1 ); if ( fs.getCache() != null ) { feature = (Feature) fs.getCache().get( gmlId ); } if ( feature == null ) { LOG.debug( "Recreating object '" + gmlId + "' from db (BLOB/hybrid mode)." ); feature = (Feature) codec.decode( rs.getBinaryStream( 2 ), fs.getNamespaceContext(), fs.getSchema(), crs, fs.getResolver() ); if ( fs.getCache() != null ) { fs.getCache().add( feature ); } } else { LOG.debug( "Cache hit." ); } fs.checkIfFeatureTypIsRequested( typeNames, feature.getType() ); } catch ( Exception e ) { String msg = "Cannot recreate feature from result set: " + e.getMessage(); throw new SQLException( msg, e ); } return feature; }
private int performDeleteBlob( IdFilter filter, Lock lock ) throws FeatureStoreException { checkIfFeaturesAreNotLocked( filter, lock ); int deleted = 0; PreparedStatement stmt = null; try { stmt = conn.prepareStatement( "DELETE FROM " + blobMapping.getTable() + " WHERE " + blobMapping.getGMLIdColumn() + "=?" ); for ( ResourceId id : filter.getSelectedIds() ) { stmt.setString( 1, id.getRid() ); stmt.addBatch(); if ( fs.getCache() != null ) { fs.getCache().remove( id.getRid() ); } } int[] deletes = stmt.executeBatch(); for ( int noDeleted : deletes ) { deleted += noDeleted; } } catch ( SQLException e ) { LOG.debug( e.getMessage(), e ); throw new FeatureStoreException( e.getMessage(), e ); } finally { JDBCUtils.close( stmt ); } LOG.debug( "Deleted " + deleted + " features." ); return deleted; }
@Override public GMLObject getObjectById( String id ) throws FeatureStoreException { GMLObject geomOrFeature = null; if ( getCache() != null ) { geomOrFeature = getCache().get( id ); } if ( geomOrFeature == null ) { if ( getSchema().getBlobMapping() != null ) { geomOrFeature = getObjectByIdBlob( id, getSchema().getBlobMapping() ); } else { geomOrFeature = getObjectByIdRelational( id ); } } return geomOrFeature; }