Thursday, July 19, 2007

Hibernate exception/solution

Today, when I added Hibernate to one of my existing project, the first error I got is this one:

org.hibernate.HibernateException: No CurrentSessionContext configured!

The cause of this problem was due to the missing configuration for the 'current_session_context_class' in either 'cfg.xml' or 'hibernate.properties'

it should be set to value 'thread' if using JDBC, because Hibernate need to bind the session to Java thread instead of Transaction of JTA (no JTA if using plain JDBC).

I think I have this configuration in my old project, but when I using the Eclipise plugin for re-engineering POJOs and 'cfg.xml', it took out the configuration.

No comments: