Allow calling hql functions not in order

Bug #772983 reported by avi
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Querydsl
Fix Released
Undecided
Unassigned

Bug Description

If the .from will be called after innerJoin it will cause an exception:

query.innerJoin(QEmployee.employee.user,QUser.user);
query.innerJoin(QUser.user.brands,QBrand.brand);
query.from(QEmployee.employee);

this not:

query.from(QEmployee.employee);
query.innerJoin(QEmployee.employee.user,QUser.user);
query.innerJoin(QUser.user.brands,QBrand.brand);

the error:

Apr 28, 2011 11:05:58 PM org.apache.catalina.core.StandardWrapperValve __invoke
SEVERE: Servlet.service() for servlet [spring] in context with path [] threw exception [Request processing failed; nested exception is org.hibernate.hql.ast.QuerySyntaxException: employee.user is not mapped [select employee
from employee.user as user

The order between:
 select,from,*Join(as a group), where(as a group),groupBy,orderBy
Should be as HQL required and not as has been called by the programmer

more details here: http://source.mysema.com/forum/mvnforum/viewthread_thread,1557_lastpage,yes#2524

Revision history for this message
Timo Westkämper (timo-westkamper) wrote :

I just added a QueryMetadata implementation for this : com.mysema.query.support.OrderedQueryMetadata

You can inject it into the constructor of the query.

OrderedQueryMetadata performs no validation of the query elements, but ensures that FROM elements are always serialized before JOIN elements. Let me know if other reorderings are necessary.

Changed in querydsl:
status: New → Fix Committed
Revision history for this message
Timo Westkämper (timo-westkamper) wrote :

The order of the rest of the elements is also ensured. The serialization process uses the following order :

select - sources (froms + joins) - where - group - having - order

Revision history for this message
avi (fatnjazzy) wrote :

Hi,
Thanks, how do I get this version to my maven?
And I did not understand the implementation, please drop me 3 lines of code.
Thanks for your kind help!

Revision history for this message
Timo Westkämper (timo-westkamper) wrote :

I didn't manage to make a new release, but the latest SNAPSHOT (2.2.0.beta4-SNAPSHOT) is now available via our Maven repository on Mysema Source.

You should be able to use the new metadata implementation like this :

  JPAQuery query = new JPAQuery(entityManager, new OrderedQueryMetadata());

or like this for the Hibernate API

  HibernateQuery query = new HibernateQuery(session, new OrderedQueryMetadata());

Revision history for this message
avi (fatnjazzy) wrote :

Hi,
I failed to get this:
 <dependency>
  <groupId>com.mysema.querydsl</groupId>
  <artifactId>querydsl-apt</artifactId>
  <version>2.2.0.beta4</version>
  <scope>provided</scope>
  </dependency>

  <dependency>
  <groupId>com.mysema.querydsl</groupId>
  <artifactId>querydsl-jpa</artifactId>
  <version>2.2.0.beta4</version>
 </dependency>

OR
2.2.0.beta4-SNAPSHOT

Thanks!

Revision history for this message
Timo Westkämper (timo-westkamper) wrote :

The last release is 2.2.0-beta4, not 2.2.0.beta4

We changed the versioning scheme a bit to simplify Querydsl / Spring Data integration

Revision history for this message
avi (fatnjazzy) wrote :

Hi,
The "new OrderedQueryMetadata()" is not in 2.2.0-beta4, Am I missing something here?
Thanks

Revision history for this message
Timo Westkämper (timo-westkamper) wrote :

It is fixed, but not yet released. You get the new code from SVN trunk. I can make a SNAPSHOT release on monday.

Revision history for this message
avi (fatnjazzy) wrote :

Hi,
Is there a new release with that fix?
Thanks

Revision history for this message
Timo Westkämper (timo-westkamper) wrote :

Released in 2.2.0.beta5

Changed in querydsl:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.