The only thing I can think of is your call to detail.getLesson(). The getLesson() must be returning NULL and your trying to call a method on the getLesson() that is null, thus your NPE. However, it is possible that the getSubject() call returns null too. Not sure. Do an if() check on it before printing it out to find out which one is null. Then go from there.
Is that data mapping problem? Because I can find the field (Lesson) in database, but when retrieve it, the field (Lesson) is null.