We'd like to get rid of having to specify all the jar files or individual classes in persistence.xml and <property name="hibernate.archive.autodetection" value="class"/>
doesn't seem to work, at least Hibernate doesn't pick up any classes that are not in any of the mentioned jar files or in the archive containing persistence.xml.
So the idea was to scan for entities ourselves and provide Hibernate with all the detected classes.
The basic approach would have been:
- use a CDI extension to pick up all classes annotated with @Entity (this works)
- use a Hibernate integrator to register the classes
However, there are two problems as it seems:
- The integrator runs before the CDI extension so the order doesn't fit.
- Logs indicate that Hibernate builds the persistence unit even before running the integrators thus adding classes in the integrator seems to be too late, even if we could solve or work around problem 1 (e.g. by scanning the classpath ourselves).
Basically the question is: How would we programmatically add persistent classes to the Hibernate configuration in a JBoss 7 or Wildfly environment?