Good day! I just started getting acquainted with Hibernate and immediately ran into a problem. In my MySQL database there is some table result , which among other things has a foreign key field test_id . I get an entity- object of the result table and want to get the same test_id field from another table. The problem is that after receiving an entity object, the session is closed and I cannot get the value from the foreign key! Tell me the solutions! PS I use the example from this article: