We have an application that uses Guice 1.0 with warp-servlet and warp-persist, and we'd like to upgrade to Guice 2 or 3. However, we're hitting a web of dependencies that is making it complicated.
Does anyone know of a simple way (as close as possible to drop-in replacement) to either make warp-persist work with newer Guice, or make Guice-persist work with straight Hibernate?
you can access the hibernate session from a JPA entity manager. This allows you to use migrate away from warp.
@Singleton
public class SessionProvider implements Provider<Session> {
/** The entity manger to retrieve the session from. */
@Inject
private Provider<EntityManager> entityManagerProvider;
/**
* @return the Hibernate session, being the delegate of the entity manager provided by the injected entity manager provider.
*/
@Override
public Session get() {
final Session session = (Session) entityManagerProvider.get().getDelegate();
return session;
}
}
All you need to do is configure Hibernate to be you JPA implementation. Also I would recommend to use onami persist. Guice persist seems to be abandoned.