Spring and hibernate: No Session found for current thread

You annotated your Dao class with @Transactional, but not your service class. The line:

Visitor storedVisitor =
    (Visitor) sessionFactory.getCurrentSession().get(Visitor.class,
            visitorDetails.getTfscNumber(), LockMode.NONE);

requires you to be in a transaction.

You can fix this by adding the @Transactional annotation to your ProfileService class, or just the registerVisitor() method.

Leave a Comment