Author: epbernard
Date: 2008-08-18 13:59:24 -0400 (Mon, 18 Aug 2008)
New Revision: 15100
Modified:
search/trunk/src/java/org/hibernate/search/engine/DocumentBuilder.java
Log:
fix infinite loop on moving up the class hierarchy in @ProvidedId
Modified: search/trunk/src/java/org/hibernate/search/engine/DocumentBuilder.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/engine/DocumentBuilder.java 2008-08-18
17:58:21 UTC (rev 15099)
+++ search/trunk/src/java/org/hibernate/search/engine/DocumentBuilder.java 2008-08-18
17:59:24 UTC (rev 15100)
@@ -115,7 +115,7 @@
this.analyzer.setGlobalAnalyzer( rootPropertiesMetadata.analyzer );
if ( idKeywordName == null ) {
// if no DocumentId then check if we have a ProvidedId instead
- ProvidedId provided = findProvidedId( clazz );
+ ProvidedId provided = findProvidedId( clazz, reflectionManager );
if ( provided == null ) throw new SearchException( "No document id in: " +
clazz.getName() );
idBridge = BridgeFactory.extractTwoWayType(provided.bridge());
@@ -126,10 +126,10 @@
safeFromTupleId = TwoWayString2FieldBridgeAdaptor.class.isAssignableFrom(
idBridge.getClass() );
}
- private ProvidedId findProvidedId(XClass clazz) {
+ private ProvidedId findProvidedId(XClass clazz, ReflectionManager reflectionManager) {
ProvidedId id = null;
XClass currentClass = clazz;
- while ( id == null && currentClass != null) {
+ while ( id == null && ( ! reflectionManager.equals( currentClass, Object.class
) ) ) {
id = currentClass.getAnnotation( ProvidedId.class );
currentClass = clazz.getSuperclass();
}