title: Hibernate query for entity with map property
body: <p>I've been struggling with a query in hibernate to update the state of an entity. Such entity, called PaymentRequestLink, is in a one to many relation with another entity called extraparameters</p>
  
  <p>PaymentRequestType.java:</p>
  
  <pre><code>@Entity
  @Table(name="payment_link")
  public class PaymentRequestLink {
  
       private Map&lt;String, ExtraParameter&lt;E&gt;&gt; extraParameters;
  
       @Fetch(FetchMode.SELECT)
       @ElementCollection(fetch=FetchType.EAGER)
       @CollectionTable(name="extraparameter_payment_link", 
         schema=BaseEntity.DATABASE_SCHEMA, joinColumns=@JoinColumn(name="extraparameter_payment_link_id"))
       @MapKeyColumn(name = "name", length=64, nullable = false)
       public Map&lt;String, ExtraParameter&lt;String&gt;&gt; getExtraParameters() {
             return extraParameters;
        }
  </code></pre>
  
  <p>ExtraParameter.java:</p>
  
  <pre><code> @Embeddable
   public class ExtraParameter&lt;T extends Serializable&gt; implements Serializable {
  
       //...
  
       @Column(name="extra_type", length=64, nullable=false)
       @NotNull
       public String getType() {
           return type;
       }
  
       @Column(name="extra_value", length=255, nullable=false)
       @NotNull
       public T getValue() {
           return value;
       }
  </code></pre>
  
  <p>This is a data example of the extraparameter_payment_link table:</p>
  
  <pre><code>extraparameter_payment_link_id  extra_type           extra_value          name
      1                           java.sql.Date        2019-01-01           EXPIRATION_DATE
  </code></pre>
  
  <p>The query I want to make is to update the state of the PaymentRequestLink to EXPIRED when the expiration date, which is stored in the extraparameters, is a date before to the current date.
  This is the query I have now:</p>
  
  <pre><code>    String stateSentence = "AND state &lt;&gt; '";
      String sqlUpdateLinkDetailed =  "UPDATE PaymentRequestLink ld SET state='EXPIRED' " +
              "WHERE extraParameters.EXPIRATION_DATE.value &lt;= ? " +
              stateSentence + PaymentRequestLinkState.PAID;
  
      Calendar calendar = Calendar.getInstance();
      calendar.add(Calendar.MINUTE, 1);
      Timestamp now = new Timestamp(calendar.getTimeInMillis());
  
      hibernateTemplate.bulkUpdate(sqlUpdateLinkDetailed, now);
  </code></pre>
  
  <p>The exception I've got is:</p>
  
  <pre><code> error processing job
   org.springframework.orm.hibernate3.HibernateQueryException: could not resolve property: EXPIRATION_DATE of: component[type,value] [UPDATE 
   com.some.company.PaymentRequestLink ld SET state='EXPIRED' WHERE extraParameters.EXPIRATION_DATE.value &lt;= ? AND state &lt;&gt; 'PAID']; nested exception is org.hibernate.QueryException: could not resolve property: EXPIRATION_DATE of: component[type,value] [UPDATE com.some.company.PaymentRequestLink ld SET state='EXPIRED' WHERE extraParameters.EXPIRATION_DATE.value &lt;= ? AND state &lt;&gt; 'PAID']
  </code></pre>
  
  <p>Can anyone help me with this?</p>