@Transactional public void remove( User user, Long resourceSid ) throws IOException { MDOAlbumResource resource = this.daoAlbumResource.get( user.getLogin(), resourceSid ); if ( resource != null ) { // first, removing the resource file String path = resource.calculateAbsolutePath( daoSettings.getSettings() ); File fpath = new File( path ); fpath.delete(); // after, removing the album data from database this.daoAlbumResource.remove( resource ); } }