Michał Tomala
Michał Tomala

Reputation: 23

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

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;

Upvotes: 2

Views: 478

Answers (1)

Musa Ay
Musa Ay

Reputation: 164

Can you try like bottom

instituonRepository.findAllByWhomHelpIn

Thanks

Upvotes: 1

Related Questions