br.com.anteros.nosql.persistence.mongodb.query.MongoKeyIterator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of Anteros-NoSql-Persistence-MongoDB Show documentation
Show all versions of Anteros-NoSql-Persistence-MongoDB Show documentation
Anteros NoSQL Persistence MongoDB.
package br.com.anteros.nosql.persistence.mongodb.query;
import java.util.Iterator;
import org.bson.Document;
import com.mongodb.DBObject;
import br.com.anteros.nosql.persistence.converters.Key;
import br.com.anteros.nosql.persistence.session.NoSQLSession;
import br.com.anteros.nosql.persistence.session.mapping.AbstractNoSQLObjectMapper;
public class MongoKeyIterator extends MongoIterator> {
public MongoKeyIterator(final NoSQLSession> session, final Iterator cursor, final AbstractNoSQLObjectMapper mapper,
final Class clazz, final String collection) {
super(session, cursor, mapper, clazz, collection, null);
}
@Override
protected Key convertItem(final Document dbObj) throws Exception {
Object id = dbObj.get(AbstractNoSQLObjectMapper.ID_KEY);
if (id instanceof DBObject) {
Class> type = getSession().getDescriptionEntityManager().getDescriptionEntity(getClazz()).getDescriptionIdField().getType();
id = getMapper().fromDocument(getSession(), type, (DBObject) id, getMapper().createEntityCache());
}
return new Key(getClazz(), getCollection(), id);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy