I'm trying to use MongoTemplate
s find
method. It wants "entity class" as the second parameter.
I give the model class for this, but it does not accept it. It also doesn't show the @Entity
annotation. The method is as follows:
mongoTemplate.find(queryBuy , Orders, "orders");
Orders
is my model class and orders is collections name. Here are the annotations at the beginning of my model class
@Getter @Setter
@Document(collection = "orders")
@Data
@JsonIgnoreProperties(ignoreUnknown = true)
public class Orders {
....
}
CodePudding user response:
MongoTemplate
find()
methods has as the second argument a [Class][1]
. You can get a Class
instance with Orders.class
. Having said this, please try the following:
mongoTemplate.find(queryBuy, Orders.class, "orders");