title: How to query for Map values with Spring Data JPA?
body: <p>so my database model goes like this: I have <code>Store</code>s and every <code>Store</code> has a localized name. So I have chosen to represent the localized name as a <code>Map</code> like this:</p>
  
  <pre><code>public class Store {
     private Map&lt;Locale,LocalizedValue&gt; name;
  }
  </code></pre>
  
  <p>as you can see it's a Map of <code>&lt;Locale, LocalizedValue&gt;</code> where the <code>LocalizedValue</code> is a class like this:</p>
  
  <pre><code>@Embeddable
  public class LocalizedValue {
  
     @Column(name = "value")
     private String value;
  }
  </code></pre>
  
  <p>and it all works great. However I get to a problem where I want to query my Spring Data JPA repository and find all the stores with a given english name. So my repository method looks like this:</p>
  
  <pre><code>Store findByName(Map.Entry&lt;Locale, LocalizedValue&gt; name);
  </code></pre>
  
  <p>but it throws this exception:</p>
  
  <pre><code> 2014-10-07 23:49:55,862 [qtp354231028-165] ERROR: Parameter value [en=Some Value] did not match expected type [com.test.LocalizedValue(n/a)]; nested exception is java.lang.IllegalArgumentException: Parameter value [en=Some Value] did not match expected type [com.test.LocalizedValue (n/a)]
  org.springframework.dao.InvalidDataAccessApiUsageException: Parameter value [en=Some Value] did not match expected type [com.test.LocalizedValue (n/a)]; 
  nested exception is java.lang.IllegalArgumentException: Parameter value [en=Some Value] did not match expected type [com.test.LocalizedValue (n/a)]
      at org.springframework.orm.jpa.EntityManagerFactoryUtils.convertJpaAccessExceptionIfPossible(EntityManagerFactoryUtils.java:384)
      at org.springframework.orm.jpa.vendor.HibernateJpaDialect.translateExceptionIfPossible(HibernateJpaDialect.java:216)
      at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.translateExceptionIfPossible(AbstractEntityManagerFactoryBean.java:417)
      at org.springframework.dao.support.ChainedPersistenceExceptionTranslator.translateExceptionIfPossible(ChainedPersistenceExceptionTranslator.java:59)
      at org.springframework.dao.support.DataAccessUtils.translateIfNecessary(DataAccessUtils.java:213)
  </code></pre>
  
  <p>So then I changed my repository method to be like this:</p>
  
  <pre><code>Store findByName(LocalizedValue name);
  </code></pre>
  
  <p>but then I got this exception:</p>
  
  <pre><code>Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 'name1_.pk' in 'where clause'
      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
      at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
  </code></pre>
  
  <p>I also tried using Contains in the query method - still no luck.</p>
  
  <p>So my question is: Is there a way to query for the stores with English name 'Some Value'?</p>