2013-03-03 75 views
3

我可以使用roo和mongodb創建查找程序嗎? 它似乎沒有支持,但我找不到任何地方這樣說。mongodb的春季Roo Finder

我得到的錯誤/信息:命令「查找列表」已找到,但當前不可用(類型的「幫助」,然後回車,以瞭解這個命令)

所以,問題是我如何創建自己的發現者?我在網上找到的所有示例都是關係數據庫,並且找不到mongodb。

非常感謝。

回答

1

您可以在Query Methods section of the Spring Data MongoDB - Reference Documentation中找到如何創建您自己的發現者。

在使用mongodb設置的Spring Roo中,您的Repository接口已經擴展了PagingAndSortingRepository。

如果您有一個模型Person,並帶有屬性「lastName」,那麼您可以在Repository接口中聲明一個方法findByLastname(String lastname)。例如。

@RooMongoRepository(domainType = Person.class) 
public interface PersonRepository { 
    List<Person> findAll(); 
    List<Person> findByLastname(String lastname); 
} 

關於如何創建其他發現者看看「表6.1。支持關鍵字查詢方法」在上面給出的鏈接。