Join condition leads to Hibernate QuerySyntaxException after Querydsl migration from 2.7.0 to 2.8.0 #250

Closed
Buttstedt opened this Issue Oct 16, 2012 · 5 comments

Comments

Projects
None yet
2 participants
@Buttstedt

We are using Hibernate 4.1.4 as persistence provider.
With Querydsl 2.7.0 the following example query which contains an additional join condition works fine:

JPAQuery query = new JPAQuery(entityManager);
query.from(cat)
.leftJoin(cat.kittens, kitten)
.with(kitten.bodyWeight.gt(10.0))
.list(cat);

Querydsl 2.7.0 generates following JPQL:
select from Cat as cat
left join cat.kittens as kitten
with kitten.bodyWeight > 10.0

Querydsl 2.8.0 generates following JPQL:
select from Cat as cat
left join cat.kittens as kitten
on kitten.bodyWeight > 10.0

and leads to Hibernate QuerySyntaxException:
org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected token: on

This seems to be a bug, because the keyword "on" is not part of JPQL specification (JPA 2.0).

timowest added a commit that referenced this issue Oct 16, 2012

@timowest

This comment has been minimized.

Show comment
Hide comment
@timowest

timowest Oct 16, 2012

Member

There is no "on" and "with" in JPA 2.0, but there is "on" in JPA 2.1 http://stackoverflow.com/questions/11100702/how-to-have-multiple-conditions-in-jpql-join

Is this the constructor you use for query creation?

JPAQuery query = new JPAQuery(entityManager);

Querydsl should successfully detect the JPQL dialect to use based on the entity manager, but maybe this fails here. Querydsl uses "with" for Hibernate and "on" for everything else.

Which container (Spring, Guice etc) are you using?

Member

timowest commented Oct 16, 2012

There is no "on" and "with" in JPA 2.0, but there is "on" in JPA 2.1 http://stackoverflow.com/questions/11100702/how-to-have-multiple-conditions-in-jpql-join

Is this the constructor you use for query creation?

JPAQuery query = new JPAQuery(entityManager);

Querydsl should successfully detect the JPQL dialect to use based on the entity manager, but maybe this fails here. Querydsl uses "with" for Hibernate and "on" for everything else.

Which container (Spring, Guice etc) are you using?

@Buttstedt

This comment has been minimized.

Show comment
Hide comment
@Buttstedt

Buttstedt Oct 16, 2012

Yes, I am using the constructor

JPAQuery query = new JPAQuery(entityManager);

I am working with GlassFish 2.1.1 (with migration to JPA 2.0)

You are right, it seems to be a problem with the dialect detection:
When using the Hibernate stand-alone EntityManager without any EJB container I am getting "with" with Querydsl 2.8.0.

Yes, I am using the constructor

JPAQuery query = new JPAQuery(entityManager);

I am working with GlassFish 2.1.1 (with migration to JPA 2.0)

You are right, it seems to be a problem with the dialect detection:
When using the Hibernate stand-alone EntityManager without any EJB container I am getting "with" with Querydsl 2.8.0.

@timowest

This comment has been minimized.

Show comment
Hide comment
@timowest

timowest Oct 16, 2012

Member

What does entityManager.getDelegate() return when JPA is managed by GlassFish? Querydsl expects a org.hibernate.Session instance.

Member

timowest commented Oct 16, 2012

What does entityManager.getDelegate() return when JPA is managed by GlassFish? Querydsl expects a org.hibernate.Session instance.

@Buttstedt

This comment has been minimized.

Show comment
Hide comment
@Buttstedt

Buttstedt Oct 17, 2012

For GlassFish entityManager.getDelegate() returns the instance org.hibernate.ejb.EntityManagerImpl.

In case of Hibernate stand-alone EntityManager (without GlassFish EJB container) getDelegate() returns the instance org.hibernate.internal.SessionImpl.

For GlassFish entityManager.getDelegate() returns the instance org.hibernate.ejb.EntityManagerImpl.

In case of Hibernate stand-alone EntityManager (without GlassFish EJB container) getDelegate() returns the instance org.hibernate.internal.SessionImpl.

timowest added a commit that referenced this issue Oct 17, 2012

@timowest

This comment has been minimized.

Show comment
Hide comment
@timowest

timowest Oct 19, 2012

Member

Released in 2.8.1

Member

timowest commented Oct 19, 2012

Released in 2.8.1

@timowest timowest closed this Oct 19, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment