From my post on the list:
I'm starting our migration to ORM 4.3 to be able to provide some (hopefully useful) feedback on ORM 4.3 and Search 4.5.
One thing we did in most of our apps was injecting Spring managed interceptor into the session factory using a trick very similar to what is explained there: http://blog.krecan.net/2009/01/24/spring-managed-hibernate-interceptor-in-jpa/.
This (kinda ugly) trick doesn't work any more in 4.3 and I ended up doing the following: https://gist.github.com/gsmet/8578138 which works but is IMHO very fragile as I only changed one initialization method and if I would have liked to change them all, I would have to duplicate a lot of code.
Would it be possible to create a protected method which centralizes the call to Bootstrap.getEntityManagerFactoryBuilder( persistenceUnit, integration, providedClassLoader ); call we could override easily? See: https://github.com/hibernate/hibernate-orm/blob/4.3/hibernate-entitymanager/src/main/java/org/hibernate/jpa/HibernatePersistenceProvider.java#L129 https://github.com/hibernate/hibernate-orm/blob/4.3/hibernate-entitymanager/src/main/java/org/hibernate/jpa/HibernatePersistenceProvider.java#L150 https://github.com/hibernate/hibernate-orm/blob/4.3/hibernate-entitymanager/src/main/java/org/hibernate/jpa/HibernatePersistenceProvider.java#L157
This way I could simply override this method to return a different EntityManagerFactoryBuilder aware of my interceptor for every way to initialize an EntityManagerFactory.
And minor nitpicking, I think the wrap method should be protected as it's used in a protected method we might want to tweak without having to implement this method again. see https://github.com/hibernate/hibernate-orm/blob/4.3/hibernate-entitymanager/src/main/java/org/hibernate/jpa/HibernatePersistenceProvider.java#L137
|