2015-04-02 99 views
0

我想確定我的所有Spring Data Gemfire查詢是否使用在Gemfire服務器上定義的索引。如何確定Spring Data Gemfire查詢是否使用Gemfire索引?

隨着OQL,我知道我可以添加「<trace>」,並在日誌中的GemFire它會顯示是否正在使用一個索引:

@Query("<trace> SELECT c FROM /customer c, c.emailAddresses email WHERE email.emailAddress = $1") 
CustomerEntity findByEmailAddress(String emailAddress); 

但在哪裏我們沒有OQL定義的方法是什麼,喜歡這個? (假設用戶名不是客戶區域的關鍵):

CustomerEntity findByUsername(String username); 

回答

0

偉大的問題。不幸的是,基於名稱中使用的方法名稱和約定生成GemFire OQL查詢的Repository方法不支持TRACE或其他OQL語​​句,如IMPORT

正如您可能知道的那樣,Spring Data GemFire's Repository support構建於Spring Data Commons Repository infrastructure之上,它保留了數據存儲支持(關係數據,鍵值,文檔等)最廣泛範圍的最小公分母。

不過,你可以啓用調試通過設置的GemFire系統屬性中的所有的GemFire OQL查詢...

-Dgemfire.Query.VERBOSE=true 

啓動應用程序時。進一步的細節見GemFire's User Guide on Query Debugging

不幸的是,如果您只想跟蹤其中一個OQL查詢,但會完成您想要的操作,這會更加冗長。

在基於Repository方法的單個OQL查詢中,TRACE唯一的其他方法是使用@Query註釋,如上所示。

@Query("<trace> SELECT c FROM /customer c, c.emailAddresses email WHERE email.emailAddress = $1") 
CustomerEntity findByEmailAddress(String emailAddress); 

雖然你的問題給了我一些想法。我想通過註解提供進口和跟蹤支持這樣的...

@Trace 
@Import("example.app.domain.CustomerEntity") 
CustomerEntity findByUsername(String username); 

這將是非常優雅的和有用的。

查看新的JIRA票證(SGF-392)我提交了對此功能的支持。

謝謝!

+0

謝謝!這非常有幫助,添加這些註釋將是一個好主意! – GeekChick 2015-04-07 16:19:45

相關問題