I'm just trying to fetch data using a foreign key and while it does it's job correctly I'm getting a strange error and i really don't know why since i found similar code on internet and it works just fine.
try {
Laptop lpa;
session.beginTransaction();
Student myStudent = session.get(Student.class, 2);
lpa = myStudent.getLaptop(); //error refers to this line of code
System.out.println(lpa.getVrsta());
session.getTransaction().commit();
session.close();
} finally {
sf.close();
}
And it gives me this error:
ERROR:
Connection leak detected: there are 1 unclosed connections upon shutting down pool jdbc:mysql://....
Exception in thread "main" java.lang.NullPointerException
at oto_otm_mtm.Blogic.main