[hibernate-dev] Integrator and retrieving objects

Emmanuel Bernard emmanuel at hibernate.org
Tue Apr 5 03:19:00 EDT 2011

In JPA and other Java specs, there is a pattern emerging where one could unwrap some objects from a common API

interface EntityManager {
  T unwrap(Class<T> type);

We typically let a Session be extracted from an EntityManager

Session session = entityManager.unwrap(Session.class);

I wonder if we want do provide a possibility for third party Hibernate integrators to let some objects be unwrapped.

FullTextSession ftSession = session.unwrap(FullTextSession.class);
//the current approach is via some static helper method
//FullTextSession ftSession =  Search.getFullTextSession(session);

That would mean that the integration point between HSearch and Hibernate would have an unwrap method and Hibernate would delegate the unwrap calls to each integrator until a non null object is returned.

It's just a thought, WDYT?

More information about the hibernate-dev mailing list