public boolean deleteTopic(int id) {
        Connection connection = ConnectionManager.getConnection();
        if (connection == null) {
            logger.log(Level.SEVERE, "Couln't establish a connection to database");
            return false;
        }
        MessageManager messageManager = new MessageManager();
        List<MessageManager.Message> messageList = messageManager.getAllChildrenMessages(id);        
        for (MessageManager.Message message : messageList) {
            messageManager.deleteMessage(message.getId());
        }
        try {
            PreparedStatement ps = connection.prepareStatement(DELETE_TOPIC_BY_ID_QUERY);
            ps.setInt(1, id);           
            return ps.execute();            
        } catch (SQLException ex) {
            logger.log(Level.SEVERE, null, ex);
            return false;
        }
    }