0
使用HQL,我想搜索排序對象的起始索引。HQL用於按預定義順序查找對象的起始索引?
舉例來說,如果我有以下持久類:
<class name="Word">
<id name="id" type="int">
<meta attribute="scope-set">protected</meta>
<generator class="native"/>
</id>
<many-to-one name="sentence" class="Sentence"/>
<property name="word" type="string"/>
<property name="num" type="integer"/>
</class>
<class name="Sentence">
<id name="id" type="int">
<meta attribute="scope-set">protected</meta>
<generator class="native"/>
</id>
<set name="words" lazy="true">
<one-to-many class="Word"/>
</set>
</class>
,我堅持禾以下RDS成句對象:
WORD NUM
----------
the 0
cow 1
jumped 2
over 3
the 4
moon 5
but 6
the 7
cow 8
forgot 9
her 10
bell 11
我想搜索「牛」,並取回0和7,「牛跳樓」的搜索只會返回0
我現在方法是一種迭代搜索 - 對第一個單詞的索引進行查詢,然後使用該索引查看下列單詞的索引是否是我想要的索引。這是一個很好的方法或有沒有辦法做到這一點所有在一個查詢?