@ -1,5 +1,5 @@
/ *
/ *
* Copyright 2011 - 2013 the original author or authors .
* Copyright 2011 - 2014 the original author or authors .
*
*
* Licensed under the Apache License , Version 2 . 0 ( the "License" ) ;
* Licensed under the Apache License , Version 2 . 0 ( the "License" ) ;
* you may not use this file except in compliance with the License .
* you may not use this file except in compliance with the License .
@ -44,6 +44,7 @@ import com.mongodb.DBRef;
* @author Jon Brisbin
* @author Jon Brisbin
* @author Oliver Gierke
* @author Oliver Gierke
* @author Patryk Wasik
* @author Patryk Wasik
* @author Thomas Darimont
* /
* /
public class QueryMapper {
public class QueryMapper {
@ -176,20 +177,22 @@ public class QueryMapper {
if ( value instanceof DBObject ) {
if ( value instanceof DBObject ) {
DBObject valueDbo = ( DBObject ) value ;
DBObject valueDbo = ( DBObject ) value ;
DBObject resultDbo = new BasicDBObject ( valueDbo . toMap ( ) ) ;
if ( valueDbo . containsField ( "$in" ) | | valueDbo . containsField ( "$nin" ) ) {
if ( valueDbo . containsField ( "$in" ) | | valueDbo . containsField ( "$nin" ) ) {
String inKey = valueDbo . containsField ( "$in" ) ? "$in" : "$nin" ;
String inKey = valueDbo . containsField ( "$in" ) ? "$in" : "$nin" ;
List < Object > ids = new ArrayList < Object > ( ) ;
List < Object > ids = new ArrayList < Object > ( ) ;
for ( Object id : ( Iterable < ? > ) valueDbo . get ( inKey ) ) {
for ( Object id : ( Iterable < ? > ) valueDbo . get ( inKey ) ) {
ids . add ( convertId ( id ) ) ;
ids . add ( convertId ( id ) ) ;
}
}
value Dbo. put ( inKey , ids . toArray ( new Object [ ids . size ( ) ] ) ) ;
result Dbo. put ( inKey , ids . toArray ( new Object [ ids . size ( ) ] ) ) ;
} else if ( valueDbo . containsField ( "$ne" ) ) {
} else if ( valueDbo . containsField ( "$ne" ) ) {
value Dbo. put ( "$ne" , convertId ( valueDbo . get ( "$ne" ) ) ) ;
result Dbo. put ( "$ne" , convertId ( valueDbo . get ( "$ne" ) ) ) ;
} else {
} else {
return getMappedObject ( ( DBObject ) value , null ) ;
return getMappedObject ( resultDbo , null ) ;
}
}
return value Dbo;
return result Dbo;
} else {
} else {
return convertId ( value ) ;
return convertId ( value ) ;