現在、フィールドの1つにgroup_concatが必要なレポートを作成しています。JPA Criteria API group_concat usage
CriteriaQuery<GameDetailsDto> criteriaQuery = criteriaBuilder
.createQuery(GameDetailsDto.class);
Root<BetDetails> betDetails = criteriaQuery.from(BetDetails.class);
Expression<String> betSelection = betDetails.get("winningOutcome");
criteriaQuery.multiselect(
// other fields to select
criteriaBuilder.function("group_concat", String.class, betSelection),
// other fields to select
);
//predicate, where clause and other filters
TypedQuery<GameDetailsDto> typedQuery = entityManager.createQuery(criteriaQuery);
これはライン上でnullポインタ例外がスローされます。
TypedQuery<GameDetailsDto> typedQuery = entityManager.createQuery(criteriaQuery);
私が間違ってcriteriaBuilderの機能メソッドを使用しましたか?
ドキュメンテーションは言います:
function(String name, Class<T> type, Expression<?>... args);
はNULLポインタのスタックトレースを含めます。 – James