I have the above domain structure where I have list of Companies in the product and the aim is not make entry in mongoDB when I have exact match for companies & productId
already present in the DB.
@Entity
public class Mobile {
@Id
private Integer id;
private String imei;
private Product productInfo;
// ...
}
@Entity
public class Product {
@Id
private Integer id;
private String productId;
private List<Company<?>> companies;
// ...
}
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME,
include = JsonTypeInfo.As.PROPERTY, property = "type")
@JsonSubTypes({
@JsonSubTypes.Type(name= "samsung", value = Samsung.class),
@JsonSubTypes.Type(name= "htc",value = Htc.class)})
public class Company<T> implements Serializable {
private static final long serialVersionUID = -8869676577723436716L;
private T companyInfo;
private String type;
// ...
}
I am using mongo template and I have tried to use find as shown below but id didn't work
template.find(Query.query(Criteria.where("product.companies").is(companList),Mobile.class);