List of usage examples for com.mongodb DBRef DBRef
public DBRef(final String collectionName, final Object id)
From source file:org.springframework.data.mongodb.core.convert.QueryMapper.java
License:Apache License
/** * Converts the given source assuming it's actually an association to another object. * //from w ww . j a v a 2s .com * @param source * @param property * @return */ protected Object convertAssociation(Object source, MongoPersistentProperty property) { if (property == null || source == null || source instanceof DBObject) { return source; } if (source instanceof DBRef) { DBRef ref = (DBRef) source; return new DBRef(ref.getCollectionName(), convertId(ref.getId())); } if (source instanceof Iterable) { BasicDBList result = new BasicDBList(); for (Object element : (Iterable<?>) source) { result.add(createDbRefFor(element, property)); } return result; } if (property.isMap()) { BasicDBObject result = new BasicDBObject(); DBObject dbObject = (DBObject) source; for (String key : dbObject.keySet()) { result.put(key, createDbRefFor(dbObject.get(key), property)); } return result; } return createDbRefFor(source, property); }