次のエンティティ クラスがあるとします。
@Entity
public class Client {
@Id private
Long id;
@CollectionTable
@ElementCollection
private List<String> accounts;
// getters and setters here
}
口座番号のいずれかが (大文字と小文字を区別しない) 検索用語と一致するすべてのクライアントを検索したいと考えています。運がない次のJPQLを試しました:
select c from Client c join c.accounts a where upper(a) = ?1
EclipseLink 2.4.2 と 2.5 の両方で、これは次の例外で失敗します。
Exception Description: Syntax error parsing [select c from Client c join c.accounts a
where upper(a) = ?1].
[53, 54] The encapsulated expression is not a valid expression.
@ElementCollection を変更して、@OneToMany のアカウント番号に本格的なエンティティを使用すると、すべて正常に機能します。また、jpql から upper() を削除すると、クエリは正常に実行されます。最終的にはこれに QueryDSL を使用したいと考えていますが、現在はこの querydsl クエリを使用しています
QClient qc = QClient.client;
StringPath a = Expressions.stringPath("a")
new JPAQuery(em).from(qc).innerJoin(qc.accounts, a).where(a.upper().eq(term)).list(qc)
そしてこれも
new JPAQuery(em).from(qc).where(qc.accounts.any().upper().eq(term)).list(qc)
おそらく同じjpqlに変換されるため、同様のエラーで失敗します。
これらのクエリを変更して、目的の結果を得るにはどうすればよいですか?