I like it. I tried to do something generically in the AS7 JPA code to
have a protected bag of such things at the container EntityManager
level. Just keep in mind that AS will try to serialize the objects when
clustering.
See
https://github.com/jbossas/jboss-as/blob/master/jpa/src/main/java/org/jbo...
protected void addExtension(Class cls, Object extension) {
extensions.put(cls, extension);
}
public <T> T unwrap(Class<T> cls) {
Object x = extensions.get(cls);
if (x != null)
return (T) x;
return getEntityManager().unwrap(cls);
}
Also see some unwrap tests in
https://github.com/jbossas/jboss-as/tree/master/testsuite/integration/src...
The SFSBHibernateSession test bean is based on the generic JPA
EntityManager.unwrap(Class) we discussed before.
Scott
On 04/05/2011 03:19 AM, Emmanuel Bernard wrote:
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?
_______________________________________________
hibernate-dev mailing list
hibernate-dev(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/hibernate-dev