2014-09-19 71 views
8

我想公開我的倉庫的新端點,它也擴展了RevisionRepository。Spring Data Rest:公開擴展Repository的Repository的新端點

@RepositoryRestResource(collectionResourceRel = "persons", itemResourceRel = "person", path = "persons") 
public interface PersonRepository extends PagingAndSortingRepository<PersonEntity, Long>, RevisionRepository<PersonEntity, Long, Integer> { 

    Revision<Integer, PersonEntity> findLastChangeRevision(@Param("id") Long id); 

    Revisions<Integer, PersonEntity> findRevisions(@Param("id") Long id); 

    Page<Revision<Integer, PersonEntity>> findRevisions(@Param("id") Long id, Pageable pageable); 

    PersonEntity findByName(@Param("name") String name); 
} 

我的問題,現在,是這些新方法不公開爲URL(findLastChangeRevisionfindRevisions),只有findByName是搜索URL下。我目前並不特別關注實際的網址格式,只要它可以工作即可。

我現在所知道的唯一的選擇是

  1. 獨立的修訂庫
  2. 創建一個新的控制器,它映射到「/」,以取代由Spring數據休息創造了一個,並添加所有存儲庫手動鏈接。我的問題之一是我的鏈接將被硬編碼(與連接到控制器不同),路徑將是相對的 - 不一定是壞的,但會使所有內容不一致。
  3. 鏈接添加到「/」映射到修訂庫

我有很多與我上面的選項保留意見。我不知道如何繼續。

+0

我也對這個問題的答案感興趣。我碰到類似的問題,我想擴展CrudRepository的API – 2014-12-28 19:11:52

回答

0

您在方法名稱中犯了錯誤。查找存儲庫類的方法應該是findByxxxxxx沒有findxxxxx

這似乎是你的代碼的問題。

@RepositoryRestResource(collectionResourceRel = "persons", itemResourceRel = "person", path = "persons") 
public interface PersonRepository extends PagingAndSortingRepository<PersonEntity, Long>, RevisionRepository<PersonEntity, Long, Integer> { 

    Revision<Integer, PersonEntity> findByLastChangeRevision(@Param("id") Long id); 

    Revisions<Integer, PersonEntity> findByRevisions(@Param("id") Long id); 

    Page<Revision<Integer, PersonEntity>> findByRevisions(@Param("id") Long id, Pageable pageable); 

    PersonEntity findByName(@Param("name") String name); 
} 
+0

我認爲問題在於findLastChangeRevision,findRevisions和findRevisions是由RevisionRepository – Chad 2015-02-22 04:00:18

+0

公開的方法您需要添加自定義控制器操作來暴露envers – 2015-12-31 08:17:26

相關問題