问题
I'm using DW with Hibernate, and trying to write a unit test for my DAO. I've based my code off this example. Unfortunately, getCurrentSession()
always throws, even immediately after a call tosessionFactory.openSession()
:
sessionFactory.openSession();
sessionFactory.getCurrentSession();
// throws org.hibernate.HibernateException: No session currently bound to execution context
My setUp
is almost identical to theirs (except for the JDBC driver and URL). Is there something obvious I'm doing wrong? Do I need to set current_session_context_class
perhaps, and if so, how? I'm not using a configuration file. Maybe I should be?
I suppose I could create my SessionFactory
more like this, but that's not the DropWizard way I think.
来源:https://stackoverflow.com/questions/63292887/no-session-currently-bound-to-execution-context-in-unit-test-with-dropwizard-h