public static Collection getAllTasks(){
        Session session = HibernateUtil.getSessionFactory().openSession();
        List answer = new ArrayList<Task>();
        try {
            session = HibernateUtil.getSessionFactory().openSession();
            answer = session.createCriteria(Task.class).list();
            System.out.println("all tasks got!");

        } catch (Exception e) {
            JOptionPane.showMessageDialog(null, e.getMessage(), "Ошибка", JOptionPane.OK_OPTION);
        } finally {
            if (session != null && session.isOpen()) {
                session.close();
            }

        }
        return answer;
    }