You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In a model with Single Table Inheritance, I would like to select objects based on their type. For this, I use the JPAExpressions.type expression:
JPAQuery query = new JPAQuery(entityManager);
query.from(parent)
.where(JPAExpressions.type(parent).in(typeList)
);
However, when my typeList is a List<String> of class names, I get:
java.lang.IllegalArgumentException: Parameter value [ChildA] did not match expected type [java.lang.Class (n/a)]
at org.hibernate.jpa.spi.BaseQueryImpl.validateBinding(BaseQueryImpl.java:874)
at org.hibernate.jpa.internal.QueryImpl.access$000(QueryImpl.java:80)
at org.hibernate.jpa.internal.QueryImpl$ParameterRegistrationImpl.bindValue(QueryImpl.java:248)
at org.hibernate.jpa.internal.QueryImpl$JpaPositionalParameterRegistrationImpl.bindValue(QueryImpl.java:337)
at org.hibernate.jpa.spi.BaseQueryImpl.setParameter(BaseQueryImpl.java:674)
at org.hibernate.jpa.spi.AbstractQueryImpl.setParameter(AbstractQueryImpl.java:198)
at org.hibernate.jpa.spi.AbstractQueryImpl.setParameter(AbstractQueryImpl.java:49)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.springframework.orm.jpa.SharedEntityManagerCreator$DeferredQueryInvocationHandler.invoke(SharedEntityManagerCreator.java:311)
at com.sun.proxy.$Proxy99.setParameter(Unknown Source)
at com.mysema.query.jpa.impl.JPAUtil.setConstants(JPAUtil.java:55)
at com.mysema.query.jpa.impl.AbstractJPAQuery.createQuery(AbstractJPAQuery.java:128)
at com.mysema.query.jpa.impl.AbstractJPAQuery.createQuery(AbstractJPAQuery.java:94)
at com.mysema.query.jpa.impl.AbstractJPAQuery.list(AbstractJPAQuery.java:245)
at ch.benediktkoeppel.test.querydsltype.ParentRepositoryCustomImpl.findByType(ParentRepositoryCustomImpl.java:18)
...
I think the typeList should be List<Class>, but the method signature does not allow this.
I agree that JPAExpressions.type could have returned this result for you, but that probably gives new issues when its used in the select clause of a query.
In a model with Single Table Inheritance, I would like to select objects based on their type. For this, I use the JPAExpressions.type expression:
However, when my typeList is a List<String> of class names, I get:
I think the typeList should be List<Class>, but the method signature does not allow this.
It could also be that I use the JPAExpressions.type wrongly. I asked a question on StackOverflow but did not get an answer: http://stackoverflow.com/questions/34568368/where-condition-based-on-jpas-type-with-querydsl
The text was updated successfully, but these errors were encountered: