2014-05-23 17 views
0

我正在使用spring和crud存儲庫。一切工作正常,但是當我這樣做查詢:在Spring中使用列表<Long>作爲參數CrudRepository

@Query("select distinct(a) from Attribute a where a.placeGroup.organization.id = ?1 and a.placeGroup.id = ?2 and a.attributeEntity = ?3 and a.id in ?4") 
List<Attribute> findAllPlaceAttributesByIds(long organizationId, long groupId, 
     Attribute.AttributeEntity type, Iterable<Long> ids); 

我有休耕例外:

Caused by: java.lang.IllegalArgumentException: Parameter value element [4] did not match expected type [java.lang.Long] 

任何想法我怎麼能解決這個問題?

+0

ids應該是Long不可迭代的 – dharr

+0

很好,但是這應該是List不是1的值 –

回答

0

事情是在某些方面,這個列表包含字符串,因爲錯誤的JSON演員。

+0

好的,你應該考慮刪除問題:) – geoand

0

findAllPlaceAttributesByOrganizationAndPlaceGroupAndIdsIn(Orgaization organizationId,PlaceGroup的groupId, Attribute.AttributeEntity類型,可迭代IDS)

應該做的伎倆。

+0

但是剩下的參數是什麼?我想使用organizationId,groupId和type也是。 –

+0

對不起,我只是想你想知道關於查詢。我認爲對於所有其他參數,您需要更改方法名稱並傳遞不是id的對象。我更新了答案。嘗試一下。 – bitkot

相關問題