@Override
	public void deleteActor(Actor actor, ActorRepository ar, ProductRepository pr) throws StorageException {
		ResultSet rs = null;
	    Connection conn = null;
	    PreparedStatement pstmt = null;
	    
	    List<Integer> filmIdsToCheckForDeletion = ar.getActorsFilmIds(actor);
	    
	    try {
			conn = Database.getConnection();
			conn.setAutoCommit(false);
			
			String query = "DELETE FROM films_actors WHERE actors_id = ?";
			pstmt = conn.prepareStatement(query);
			pstmt.setInt(1, actor.getActorId());
			pstmt.executeUpdate();
			
			query = "DELETE FROM actors WHERE actors.id = ?";
			pstmt.close();
			pstmt = conn.prepareStatement(query);
			pstmt.setInt(1, actor.getActorId());
			pstmt.executeUpdate();
			
			for(int i : filmIdsToCheckForDeletion) {
				boolean exists = ar.getIfFilmIdStillExistOnAnyActorId(i);
				
				if(!exists) {
					int productIdToDelete = pr.getProductIdOnFilmId(i);
					
					query = "DELETE FROM products_categories WHERE products_categories.products_id = ?;";
					pstmt.close();
					pstmt = conn.prepareStatement(query);
					pstmt.setInt(1, productIdToDelete);
					pstmt.executeUpdate();
					
					query = "DELETE FROM films WHERE films.products_id = ?;";
					pstmt.close();
					pstmt = conn.prepareStatement(query);
					pstmt.setInt(1, productIdToDelete);
					pstmt.executeUpdate();
					
					query = "DELETE FROM shoppingbasket WHERE shoppingbasket.products_id = ?;";
					pstmt.close();
					pstmt = conn.prepareStatement(query);
					pstmt.setInt(1, productIdToDelete);
					pstmt.executeUpdate();
					
					query = "DELETE FROM products WHERE products.id = ?;";
					pstmt.close();
					pstmt = conn.prepareStatement(query);
					pstmt.setInt(1, productIdToDelete);
					pstmt.executeUpdate();
				}
			}
			
			conn.commit();
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
			throw new StorageException(e.getMessage());
		} catch (SQLException e) {
			try {
				conn.rollback();
			} catch (SQLException e1) {
				e1.printStackTrace();
				throw new StorageException(e1.getMessage());
			}
			e.printStackTrace();
			throw new StorageException(e.getMessage());
		} finally {
			try {
				if(rs != null) {
					rs.close();
				}
				if(pstmt != null) {
					pstmt.close();
				}
				if(conn != null) {
					conn.close();
				}
			} catch (SQLException e) {
				e.printStackTrace();
				throw new StorageException(e.getMessage());
			}
		}
	}