mysema/querydsl — Issue #24: SubQuery problem
Author: jmlmoreno
Created: 2011-10-09 21:11:41+00:00
State: open

Hi everybody!!

I am new to QueryDSL, and i have a question about how to use subquerys:

Here my code:

QReposicion qreposicion = QReposicion.reposicion;
QEstadoReposicion qestadoreposicion = QEstadoReposicion.estadoReposicion;
QEstadoReposicion otraRepo = new QEstadoReposicion("otraRepo");

JPQLQuery query = from(qestadoreposicion).leftJoin(qestadoreposicion.reposicion, qreposicion);
query.where(qreposicion.impresora.id.eq(idImp));

query.where(qestadoreposicion.fechaReposicion.in(new HibernateSubQuery().from(otraRepo).
groupBy(otraRepo.reposicion.id).
having(otraRepo.reposicion.id.eq(qestadoreposicion.reposicion.id)).
list(otraRepo.fechaReposicion.max())));
return query.list(qestadoreposicion);

My problem is:

Caused by: java.lang.IllegalArgumentException: Undeclared path otraRepo
at com.mysema.query.types.ValidatingVisitor.visit(ValidatingVisitor.java:48)
at com.mysema.query.types.ValidatingVisitor.visit(ValidatingVisitor.java:10)
at com.mysema.query.types.path.NumberPath.accept(NumberPath.java:45)
at com.mysema.query.types.ValidatingVisitor.visit(ValidatingVisitor.java:101)
at com.mysema.query.types.ValidatingVisitor.visit(ValidatingVisitor.java:61)
at com.mysema.query.types.ValidatingVisitor.visit(ValidatingVisitor.java:10)
at com.mysema.query.types.query.ListSubQuery.accept(ListSubQuery.java:60)
at com.mysema.query.types.ValidatingVisitor.visit(ValidatingVisitor.java:101)
at com.mysema.query.types.ValidatingVisitor.visit(ValidatingVisitor.java:36)
at com.mysema.query.types.ValidatingVisitor.visit(ValidatingVisitor.java:10)
at com.mysema.query.types.expr.BooleanOperation.accept(BooleanOperation.java:44)
at com.mysema.query.DefaultQueryMetadata.validate(DefaultQueryMetadata.java:298)
at com.mysema.query.DefaultQueryMetadata.addWhere(DefaultQueryMetadata.java:140)
at com.mysema.query.support.QueryMixin.where(QueryMixin.java:375)
at com.mysema.query.support.QueryBase.where(QueryBase.java:44)
at com.mysema.query.jpa.impl.JPAQuery.where(JPAQuery.java:22)
at es.esoj.printSoft.modelodatos.repository.impl.RepositorioEstadosReposicionImpl.obtenerReposiciones(RepositorioEstadosReposicionImpl.java:59)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:309)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:155)
... 52 more

Why undeclared path 'otraRepo'?

Thanks in advance

--
QuerDsl: 2.2.3
SpringData-jpa: 1.0.1
Spring.3.0.6