Do you need to write your own annotation and link it up to your special two session listener?
I wrote a @UnitOfWorkWithDetach annotation that runs a hibernate session, but also detaches the result fully from Hibernate. See here for the code, you can probably figure out how to implement your own annotation in a similar way: https://github.com/rupertlssmith/jenerator_utils/blob/master/util_dropwizard_0.9/src/main/java/com/thesett/util/transaction/UnitOfWorkWithDetachApplicationListener.java I am guessing that @UnitOfWork is already registered as standard by DropWizard, so re-registering it to your listener may be why it does not work? On Tuesday, July 12, 2016 at 7:07:31 AM UTC+1, Shinhau Huang wrote: > > Hi all, > I have implemented the UnitOfWorkApplicationListener for accessing two > database in one requests. > And I also use @UnitOfWork in Jersey class. > But I still could not get the session at runtime, Are there are there any > suggestion? > Or are there some documents to use the UnitOfWorkApplicationListener > correctly? > > Thank you so much. > > @Override > > public void run(MobileAppConfiguration configuration, Environment > environment) throws Exception { > > final UserDao userDao = new > UserDao(hibernatebudleA.getSessionFactory()); > final AuthUserTokenDao authUserTokenDao = new > AuthUserTokenDao(hibernatebudleB.getSessionFactory()); > > UnitOfWorkApplicationListener listener = new > UnitOfWorkApplicationListener("hibernate.gouser", > hibernatebudleB.getSessionFactory()); > > test.registerSessionFactory("hibernate", hibernatebudleA.getSessionFactory()); > > environment.jersey().register(listener); > > environment.jersey().register(new LoginResource(userDao, > authUserTokenDao)); > > } > -- You received this message because you are subscribed to the Google Groups "dropwizard-user" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
