mirror of
https://github.com/querydsl/querydsl.git
synced 2026-06-30 21:08:30 +08:00
changed null handling to be compatible with Nullable cases
This commit is contained in:
parent
0305cfc361
commit
adc7917cc3
@ -12,6 +12,7 @@ import java.util.List;
|
||||
import com.google.code.morphia.Datastore;
|
||||
import com.google.code.morphia.Morphia;
|
||||
import com.google.code.morphia.mapping.cache.DefaultEntityCache;
|
||||
import com.mongodb.BasicDBObject;
|
||||
import com.mongodb.DBCollection;
|
||||
import com.mongodb.DBCursor;
|
||||
import com.mongodb.DBObject;
|
||||
@ -37,6 +38,8 @@ import com.mysema.query.types.Predicate;
|
||||
public class MongodbQuery<K> implements SimpleQuery<MongodbQuery<K>>,
|
||||
SimpleProjectable<K> {
|
||||
|
||||
private static final MongodbSerializer serializer = new MongodbSerializer();
|
||||
|
||||
private final QueryMixin<MongodbQuery<K>> queryMixin;
|
||||
|
||||
private final EntityPath<K> ePath;
|
||||
@ -47,8 +50,6 @@ public class MongodbQuery<K> implements SimpleQuery<MongodbQuery<K>>,
|
||||
|
||||
private final DBCollection coll;
|
||||
|
||||
private final MongodbSerializer serializer = new MongodbSerializer();
|
||||
|
||||
private final DefaultEntityCache cache = new DefaultEntityCache();
|
||||
|
||||
public MongodbQuery(Morphia morphiaParam, Datastore datastore,
|
||||
@ -175,7 +176,12 @@ public class MongodbQuery<K> implements SimpleQuery<MongodbQuery<K>>,
|
||||
|
||||
private DBObject createQuery() {
|
||||
QueryMetadata metadata = queryMixin.getMetadata();
|
||||
return (DBObject) serializer.handle(metadata.getWhere());
|
||||
if (metadata.getWhere() != null){
|
||||
return (DBObject) serializer.handle(metadata.getWhere());
|
||||
}else{
|
||||
return new BasicDBObject();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -23,8 +23,8 @@ import com.mysema.query.types.*;
|
||||
*/
|
||||
public class MongodbSerializer implements Visitor<Object, Void> {
|
||||
|
||||
public Object handle(Expression<?> where) {
|
||||
return where != null ? where.accept(this, null) : new BasicDBObject();
|
||||
public Object handle(Expression<?> expression) {
|
||||
return expression.accept(this, null);
|
||||
}
|
||||
|
||||
public DBObject toSort(List<OrderSpecifier<?>> orderBys) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user