I resolved this problem with Morphia's BasicDAO. I created a DeveloperDAO class that inherits Morphia's BasicDAO class then I used DAO methods in order to make queries and it works.
public class DeveloperDAO extends BasicDAO<Developer, String> {
public DeveloperDAO(String dbName) throws UnknownHostException {
super(MongoSingleton.getInstance(), MorphiaSingleton.getInstance(), dbName);
} }
Test
public class Test {
public static void main(String[] args) throws UnknownHostException {
DeveloperDAO developerDAO = new DeveloperDAO("test");
for(Developer developer : developerDAO.find().asList())
System.out.println(developer.getFoo());
}}