1

I want to find a Type document by the code of job and by the list of code of category, i tried the below query but it didn't work

@Document
public class Type {
    @Id
    private String id;
    @DBRef
    private Job job;
    @DBRef
    private List<Category> categories;
}

public class Job {
    @Id
    private String id;
    private String code;
}

public class Category {
    @Id
    private String id;
    private String code;
}

public interface TypeRepository extends MongoRepository<Type, String> {
    @Query("{ 'job.code': ?0, 'category.code': { $in: ?1 }}")
    Type findByJobAndCategoriesCode(String codeJob, List<String> codeCategories);
}

1 Answer 1

1

try using this one

public interface TypeRepository extends MongoRepository<Type, String> {

    Type findOneByJobCodeAndCategoriesCodeIn(String codeJob, List<String> codeCategories);
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.