2

11 で始まる ID を取得する方法を見つける必要があります。SQL では 'start with' と 'Connect by before' を使用していますが、HQL ではどうすればそれを行うことができますか? grails でより良い方法がある場合は、ヘルプ素晴らしいでしょう、ありがとう!

(更新:申し訳ありませんが、「事前に接続する」という他のコマンドを書きませんでした)

4

3 に答える 3

4

ID が文字列であると仮定すると、単純に like 句を使用しない理由は次のとおりです。

where id like '11%'

文字列ではないと仮定すると、文字列にキャストできます。

where cast(id as STRING) like '11%'

また

where str(id) like '11%'
于 2012-09-25T19:10:05.933 に答える
0

ID が 11 以上のレコードのクエリを意味する場合、たとえば Books のテーブルがある場合、HQL は次のようになります。

def books = Books.executeQuery("SELECT b from Books b WHERE id >= 11")
于 2012-09-25T19:10:45.650 に答える
0

Recursive SQL queries are non-standard so HQL does not support them (although I found a paper that appears to propose and prototype adding support). To do them you'll need to stick with SQL. Here's a similar question.

于 2012-09-25T20:20:34.627 に答える