首页 > java > 使用List <Long>作为Spring CrudRepository中的参数

使用List <Long>作为Spring CrudRepository中的参数 (Using List<Long> as parameter in Spring CrudRepository)

问题

我正在使用spring和crud存储库。一切正常,但当我这样做时:

@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]

任何想法我怎么能解决这个问题?

解决方法

事情是,由于错误的Json演员,这个List在某种程度上包含了Strings。

问题

I'm working with spring and crud repositories. All works fine but when i do that query:

@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);

I've got fallowing Exception:

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

Any ideas how can i solve this?

解决方法

Thing was that in some way this List contained Strings because of wrong Json cast.

相似信息