Skip to content

Commit cd31847

Browse files
committed
HHH-16548 add scanning of CWD with HibernatePersistenceConfiguration
1 parent d90704e commit cd31847

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

hibernate-core/src/main/java/org/hibernate/boot/model/process/internal/ScanningCoordinator.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,10 @@ private static Scanner buildScanner(BootstrapContext bootstrapContext, ClassLoad
9999
return factory.getScanner( archiveDescriptorFactory );
100100
}
101101
else {
102-
// todo: add a debug message that there is no Scanner?
102+
if ( bootstrapContext.getScanOptions().canDetectUnlistedClassesInRoot() ) {
103+
throw new IllegalStateException( "No ScannerFactory available"
104+
+ " (add 'hibernate-scan-jandex' dependency or disable 'hibernate.archive.autodetection')" );
105+
}
103106
return new DisabledScanner();
104107
}
105108
}

hibernate-core/src/main/java/org/hibernate/jpa/boot/spi/PersistenceConfigurationDescriptor.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
*/
55
package org.hibernate.jpa.boot.spi;
66

7+
import java.io.File;
8+
import java.net.MalformedURLException;
79
import java.net.URL;
810
import java.util.List;
911
import java.util.Properties;
@@ -125,7 +127,14 @@ public ClassTransformer getClassTransformer() {
125127

126128
@Override
127129
public URL getPersistenceUnitRootUrl() {
128-
return null;
130+
// When hibernate.archive.autodetection=class
131+
// scan the CWD for entities (useful for tests)
132+
try {
133+
return new File( System.getProperty("user.dir") ).toURI().toURL();
134+
}
135+
catch ( MalformedURLException e ) {
136+
return null;
137+
}
129138
}
130139

131140
@Override

0 commit comments

Comments
 (0)