Querying Morphia by Id

后端 未结 3 514
傲寒
傲寒 2021-01-13 11:09

I am using Morphia, the Pojo mapper for MongoDB, and I find difficult a task that in my view should be very simple: getting an object by id. I am able to find all the object

3条回答
  •  不知归路
    2021-01-13 11:44

    This question seems incomplete.

    It also seems like the answer to you question is on the Morphia QuickStart page. Seems to be as simple as follows.

    Datastore ds = morphia.createDatastore("testDB");
    String hotelId = ...; // the ID of the hotel we want to load
    // and then map it to our Hotel object
    Hotel hotel = ds.get(Hotel.class, hotelId);
    

    So you'll definitely need more details.

提交回复
热议问题