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;
!like ` if(! institution.getWhomHelp().isEmpty()){ return institutionRepository.findAllByWhomHelp(institution.getWhomHelp()); }`institution.getWhomHelp()isn't empty - i checked this before.This is the way when listinstitution.getInstitutionLocations()is empty andwhomHelpisn't. I've also take care of NullPointerException