Я использую Spring Boot QueryDSL для фильтрации своих сущностей и Spring Boot-Page-Feature для разбиения на страницы и сортировки, чтобы я мог вызвать следующий метод:
Page<Country> all=countryRepository.findAll(predicate,pageable);
Теперь, скажем, со следующим запросом я хочу чтобы отфильтровать все страны, где собранные переводы объектов имеют languageid с "de":
http://localhost:8090/countries?translations.languages.id=de
Я получаю следующий результат:
[
{
"id": "DE",
"currency": "EUR",
"preSelection": 49,
"currencySign": "€",
"translations": [
{
"id": "11",
"name": "Deutschland",
"text": null,
"languageId": "de"
},
{
"id": "322",
"name": "Allemagne",
"text": null,
"languageId": "fr"
},
{
"id": "18",
"name": "Germany",
"text": null,
"languageId": "en"
}
]
},
{
"id": "ES",
"currency": "EUR",
"preSelection": 34,
"currencySign": "€",
"translations": [
{
"id": "16",
"name": "Spanien",
"text": null,
"languageId": "de"
},
{
"id": "23",
"name": "Spain",
"text": null,
"languageId": "en"
}
]
},
{
"id": "PT",
"currency": "EUR",
"preSelection": 351,
"currencySign": "€",
"translations": [
{
"id": "24",
"name": "Portugal",
"text": null,
"languageId": "en"
},
{
"id": "17",
"name": "Portugal",
"text": null,
"languageId": "de"
}
]
}
]
Хорошо, что сработало! Но теперь я хочу отсортировать объекты своих стран по собранным переводам. Объекты основаны на их немецких именах:
http://localhost:8090/countries?translations.languages.id=de&sort=translations.name
Результат:
[
{
"id": "DE",
"currency": "EUR",
"preSelection": 49,
"currencySign": "€",
"translations": [
{
"id": "11",
"name": "Deutschland",
"text": null,
"languageId": "de"
},
{
"id": "322",
"name": "Allemagne",
"text": null,
"languageId": "fr"
},
{
"id": "18",
"name": "Germany",
"text": null,
"languageId": "en"
}
]
},
{
"id": "DE",
"currency": "EUR",
"preSelection": 49,
"currencySign": "€",
"translations": [
{
"id": "11",
"name": "Deutschland",
"text": null,
"languageId": "de"
},
{
"id": "322",
"name": "Allemagne",
"text": null,
"languageId": "fr"
},
{
"id": "18",
"name": "Germany",
"text": null,
"languageId": "en"
}
]
},
{
"id": "DE",
"currency": "EUR",
"preSelection": 49,
"currencySign": "€",
"translations": [
{
"id": "11",
"name": "Deutschland",
"text": null,
"languageId": "de"
},
{
"id": "322",
"name": "Allemagne",
"text": null,
"languageId": "fr"
},
{
"id": "18",
"name": "Germany",
"text": null,
"languageId": "en"
}
]
},
{
"id": "PT",
"currency": "EUR",
"preSelection": 351,
"currencySign": "€",
"translations": [
{
"id": "24",
"name": "Portugal",
"text": null,
"languageId": "en"
},
{
"id": "17",
"name": "Portugal",
"text": null,
"languageId": "de"
}
]
},
{
"id": "PT",
"currency": "EUR",
"preSelection": 351,
"currencySign": "€",
"translations": [
{
"id": "24",
"name": "Portugal",
"text": null,
"languageId": "en"
},
{
"id": "17",
"name": "Portugal",
"text": null,
"languageId": "de"
}
]
},
{
"id": "ES",
"currency": "EUR",
"preSelection": 34,
"currencySign": "€",
"translations": [
{
"id": "16",
"name": "Spanien",
"text": null,
"languageId": "de"
},
{
"id": "23",
"name": "Spain",
"text": null,
"languageId": "en"
}
]
},
{
"id": "ES",
"currency": "EUR",
"preSelection": 34,
"currencySign": "€",
"translations": [
{
"id": "16",
"name": "Spanien",
"text": null,
"languageId": "de"
},
{
"id": "23",
"name": "Spain",
"text": null,
"languageId": "en"
}
]
}
]
Ну, это не сработало! Есть ли возможность заставить это работать?
Заранее благодарим за каждый ответ.