Java Spring框架:findBy引发非法参数异常

Java Spring框架:findBy引发非法参数异常,java,spring,persistence,spring-data-jpa,Java,Spring,Persistence,Spring Data Jpa,这是我的实体类 @Entity public class Profile { @Id @GeneratedValue(strategy=GenerationType.AUTO) private Long profileId; @Transient private String name; @ElementCollection(fetch = FetchType.EAGER) private Map<String, String> trNames; //Key: Lang

这是我的实体类

@Entity
public class Profile {

@Id
@GeneratedValue(strategy=GenerationType.AUTO)
private Long profileId;

@Transient
private String name;

@ElementCollection(fetch = FetchType.EAGER)
private Map<String, String> trNames;     //Key: LanguageCode, Value: translated text
...
}
抛出异常

org.springframework.dao.InvalidDataAccessApiUsageException: Parameter value [en] did not match expected type [java.util.Map]; nested exception is java.lang.IllegalArgumentException: Parameter value [en] did not match expected type [java.util.Map]
    at org.springframework.orm.jpa.EntityManagerFactoryUtils.convertJpaAccessExceptionIfPossible(EntityManagerFactoryUtils.java:301)
    at etc..
谁能帮帮我吗

非常感谢。

这应该行得通

@Query("select p from Profile p where p.trNames[?1] = ?2")
Profile findByTrNames(String code, String name);
更新


JIRA票证是为了支持此功能而创建的:

great。。的确如此。:)你能解释一下它为什么抛出异常吗?为什么它需要java.util.Map类型?
spring数据
基于您声明的方法名
findByTrNames
构造查询。由于
trNames
属于
Map
类型,因此它希望参数也是
Map
。我同意当涉及实体中的
Map
字段时,它可能会更聪明一些,因为它们有些特定,而且方法中的两个参数可以解释为key和value是有意义的。是的,我现在理解了。非常感谢。:)@佩德拉格-你有没有可能在JIRA开一张票来改进地图装订?“我相信我们可以勾勒出一些东西来。”奥利维耶克谢谢你的建议,我已经为此开了一张罚单,用问题参考更新了我的答案
org.springframework.dao.InvalidDataAccessApiUsageException: Parameter value [en] did not match expected type [java.util.Map]; nested exception is java.lang.IllegalArgumentException: Parameter value [en] did not match expected type [java.util.Map]
    at org.springframework.orm.jpa.EntityManagerFactoryUtils.convertJpaAccessExceptionIfPossible(EntityManagerFactoryUtils.java:301)
    at etc..
@Query("select p from Profile p where p.trNames[?1] = ?2")
Profile findByTrNames(String code, String name);