Problem with sql - java.sql.SQLException: Operand should contain 1 column(s) (once

Michał Tomala :

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;
Musa Ay :

Can you try like bottom

instituonRepository.findAllByWhomHelpIn

Thanks

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=158621&siteId=1