2

I'm using Spring Data for select operation on MySql DataBase.

I'm trying to get all Institutions by listOfWhomHelp. I expected all records(institutions) which contain listOfWhomHelp, but if I choose more than one element in listOfWhomHelp it throws me:

java.sql.SQLException: Operand should contain 1 column(s)
com.mysql.jdbc.SQLError.createSQLException(SQLError.java:963)  

Repository method

List<Institution> findAllByWhomHelp(List<InstitutionListOfWhomHelp> institutionListOfWhomHelp);

Service method

public List<Institution> findInstitutions(Institution institution) throws NullPointerException {

    if(institution.getInstitutionLocations().isEmpty()){
        return institutionRepository.findAllByWhomHelp(institution.getWhomHelp());
    }
}

There is also list of InstitutionLocation, but I always choose on of them

Institution

@NotEmpty
@ManyToMany
private List<InstitutionListOfWhomHelp> whomHelp;

InstitutionListOfWhomHelp

@NotBlank
private String whomHelp;

@ManyToMany(mappedBy = "whomHelp")
private List<Institution> institution;
3
  • don't you think it should use ! like ` if(! institution.getWhomHelp().isEmpty()){ return institutionRepository.findAllByWhomHelp(institution.getWhomHelp()); }` Commented Mar 26, 2019 at 5:03
  • you can check here or here. Commented Mar 26, 2019 at 5:07
  • But the problem is that institution.getWhomHelp() isn't empty - i checked this before.This is the way when list institution.getInstitutionLocations() is empty and whomHelp isn't. I've also take care of NullPointerException Commented Mar 26, 2019 at 6:03

1 Answer 1

1

Can you try like bottom

instituonRepository.findAllByWhomHelpIn

Thanks

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.