2013-06-11 72 views
10

因此,我知道我可以編寫如下所示的接口,並且Spring Data會自動爲我生成必要的數據庫訪問內容。現在我想要做的是添加一個新的方法名稱,該名稱將計算符合一組條件的實體的數量。如何在Spring Data中編寫「Count By」方法名稱查詢

public interface EventRegistrationRepository extends JpaRepository<EventRegistration, String> 
{  
    List<EventRegistration> findByUser_EmailAddress(String email); 

    int countByEvent_Code(String eventCode); 
} 

由於現在countBy方法會導致這個錯誤:

Caused by: org.springframework.data.mapping.PropertyReferenceException: No property count found for type com.brazencareerist.brazenconnect.model.relational.EventRegistration 

什麼是什麼,我想在這裏做正確的語法?

回答

14

這與預期的just released Spring Data JPA 1.4.0.M1一樣。

+0

耶正是我們需要的! –

+2

太棒了,謝謝奧利弗。春天數據岩石! – HappyCoder86

+1

hey oli!鏈接已經死亡 –

相關問題