Ability to customize Scanner strategies
Description
Activity
Steve EbersoleMarch 21, 2011 at 7:09 PM
Bulk closing stale resolved issues
Emmanuel BernardMarch 23, 2010 at 2:25 PM
yep, <jar-file/> has been designed for this exact use case.
About HHH-4870, I've commented on the case: It's a weak area (prone to bugs) but we can't reproduce the claims so far. Help would be welcome

Andreas Joseph KroghMarch 22, 2010 at 9:31 PM
Hi Emmanuel, nice to see communication works around here
I did read your post this weekend when trying to port some infrastructure-code to JPA2 (using Hibernate of course) without much success. I've never actually used the <jar-file> element in persistence.xml for anything before as I like to configure all using Spring, but are you telling me that it's possible to split up one persistent-unit across several jar-files using this technique? I really need all entities, spread around different jar-files in different maven-modules, participating in the same transaction.
I also ran into issue which I worked around setting hibernate.ejb.metamodel.generation=disabled as suggested, although I'm not sure exactly what the effect of that is.
Emmanuel BernardMarch 22, 2010 at 9:07 PM
Hi Andreas.
Yes, I think it should work if you write your custom scanner that goes and does some merging magic.
But again a JPA app is perfectly modularizable. Just follow the JPA constructs for that. http://lists.jboss.org/pipermail/hibernate-dev/2010-February/004810.html

Andreas Joseph KroghMarch 22, 2010 at 8:42 PM
Does this affect in any way, making it possible to merge persistent-units spread over multiple modules/jars? Any sufficiently modular application would be designed this way so it's very surprising Hibernate/JPA2 doesn't support this "out of the box".
I work on 2 projects relying on the approach described here http://ancientprogramming.blogspot.com/2007/05/multiple-persistencexml-files-and.html and I don't see an easy migration-path to JPA2.
hibernate.ejb.resource_scanner
By default, Hibernate EntityManager scans itself the list of resources for annotated classes and persistence deployment descriptors (like orm.xml and hbm.xml files).
You can customize this scanning strategy by implementing org.hibernate.ejb.packaging.Scanner. This property is used by container implementors to improve integration with Hibernate.
Accepts an instance of Scanner or the file name of a no-arg constructor class implementing Scanner.