Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
クラスのプロパティを使用する関数でクエリを注文したいと考えています。何かのようなもの:
@entity class A { private int id; private String name; public int StringLength() { return name.length(); } }
そして、次のような文: select n from A order by name.StringLength(). 出来ますか?
select n from A order by name.StringLength()
いいえ、できませんが、プロパティの 1 つの長さに基づいてクエリを実行する場合は、SQL に似た長さ関数を使用できます。
select n from A order by length(name)
David の答えは正しかった - 関数を呼び出すことはできません - しかし、EJBQL では、クエリは次のようになります。
select n from A n order by length(n.name)