title: QueryDSL + PathBuilder + cast to string
body: <p>I am filtering PrimeFaces DataTables using dynamic filters.I have this working using Spring <code>org.springframework.data.jpa.domain.Specification</code>.Now I am wondring how to do the same using QueryDSL.</p>
  
  <p>Using specification I can use <code>javax.persistence.criteria.Root</code> to get a <code>javax.persistence.criteria.Join</code>, use <code>javax.persistence.criteria.Expression.as(Class&lt;String&gt; type)</code> to cast it to String and finally use <code>javax.persistence.criteria.CriteriaBuilder.like(Expression&lt;String&gt; x, String pattern, char escapeChar)</code>.</p>
  
  <p>How do I do the same in QueryDSL ? I can get PathBuilder using <code>new PathBuilder&lt;T&gt;(clazz, "entity")</code> (do you really have to use the variable here? I would like my class to be generic...) but then the <code>com.mysema.query.types.path.PathBuilder.get(String property)</code> returns new PathBuilder instead of an Expression.</p>
  
  <p>If I try to use <code>com.mysema.query.types.path.PathBuilder.getString(String property)</code> I get <code>java.lang.IllegalArgumentException: Parameter value [1] did not match expected type [java.lang.Integer]</code>.</p>
  
  <p>Seems like the part I am missing is the cast.
  I'm quite sure someone was dealing with the same thing already.</p>
  
  <p>Thanks.</p>
  
  <p><strong>Edit: Stack trace for IllegalArgumentException</strong></p>
  
  <p>Trying to search for text "1" inside integer column using <code>com.mysema.query.types.path.PathBuilder.getString(String property)</code> - that's where I need the cast to happen :</p>
  
  <p><code>Caused by: java.lang.IllegalArgumentException: Parameter value [1] did not match expected type [java.lang.Integer]
      at org.hibernate.ejb.AbstractQueryImpl.validateParameterBinding(AbstractQueryImpl.java:375)
      at org.hibernate.ejb.AbstractQueryImpl.registerParameterBinding(AbstractQueryImpl.java:348)
      at org.hibernate.ejb.QueryImpl.setParameter(QueryImpl.java:375)
      at org.hibernate.ejb.QueryImpl.setParameter(QueryImpl.java:442)
      at org.hibernate.ejb.QueryImpl.setParameter(QueryImpl.java:72)
      at com.mysema.query.jpa.impl.JPAUtil.setConstants(JPAUtil.java:44)
      at com.mysema.query.jpa.impl.AbstractJPAQuery.createQuery(AbstractJPAQuery.java:130)
      at com.mysema.query.jpa.impl.AbstractJPAQuery.createQuery(AbstractJPAQuery.java:97)
      at com.mysema.query.jpa.impl.AbstractJPAQuery.list(AbstractJPAQuery.java:240)
      at org.springframework.data.jpa.repository.support.QueryDslJpaRepository.findAll(QueryDslJpaRepository.java:102)
      ...</code></p>