У меня есть две сущности:
A id bigint auto_inctement b_id bigint B id bigint date timestamp
и код:
public void test2() {
B b = getBByA(3l);
System.out.println(b.getDate()); // <--- lazy initialization exception
}
public Revision getBByA(long a_id) {
Session session = HibernateUtil.getSessionFactory().openSession();
try {
A a = (A) session.get(A.class, a_id);
return a.getB();
} catch (RuntimeException e) {
e.printStackTrace();
throw e;
} finally {
session.close();
}
}
Как правильно получить b.getDate()? (без ленивого = "нетерпеливого")