我有一个spring crud存储库:
@Repository
public interface CrudCVVacancyMatchRepository extends CrudRepository<CVVacancyMatchEntity, Long> {
CVVacancyMatchEntity
对象具有Vacancy
属性。我试图在Vacancy
属性的属性上编写查询方法。
以下查询方法正常工作(Vacancy
有一个名为name的字符串属性):
Iterable<CVVacancyMatchEntity> findByVacancyName(String name);
但Vacancy
也有属性作为集合:
@ManyToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
@JoinTable(name = "vacancy_industries", joinColumns = { @JoinColumn(name = "fk_vacancy", referencedColumnName = "id") }, inverseJoinColumns = { @JoinColumn(name = "fk_industry", referencedColumnName = "id") })
private final Set<IndustryEntity> industries = Sets.newHashSet();
这不起作用:
Iterable<CVVacancyMatchEntity> findByVacancyIndustries(Set<IndustryEntity> industryEntities);
我得到ERROR SqlExceptionHelper:146 - Syntax error in SQL statement
select cvvacancym0_.id as id1_19_, cvvacancym0_.comment as comment2_19_, cvvacancym0_.cv_id as cv_id4_19_, cvvacancym0_.rating as rating3_19_, cvvacancym0_.user_id as user_id5_19_, cvvacancym0_.vacancy_id as vacancy_6_19_ from cv_vacancy_match cvvacancym0_ cross join vacancy vacancyent1_ cross join vacancy_industries industries2_, industry industryen3_ where cvvacancym0_.vacancy_id=vacancyent1_.id and vacancyent1_.id=industries2_.fk_vacancy and industries2_.fk_industry=industryen3_.id and .=? [42001-182]
有什么想法吗?