Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"not in" clause occurs error in hibernate #516

Closed
0xlee opened this issue Oct 7, 2013 · 10 comments
Closed

"not in" clause occurs error in hibernate #516

0xlee opened this issue Oct 7, 2013 · 10 comments
Milestone

Comments

@0xlee
Copy link

@0xlee 0xlee commented Oct 7, 2013

querydsl-core: 3.2.3
hibernate-core: 4.2.6.Final

A query generated with notIn method looks like follows:

not (field in ?1)

but it seems that hibernate tries to parse the parentheses into a vector, therefore in my opinion, it should look like:

field not in ?1

in order to be excepted by hibernate.

I'm a beginner in querydsl and hibernate. Could someone help me out?

timowest added a commit that referenced this issue Oct 7, 2013
@timowest
Copy link
Member

@timowest timowest commented Oct 7, 2013

Do you get an Exception?

@buechele
Copy link

@buechele buechele commented Oct 8, 2013

I can confirm that there is an issue.

Example:

    public long testNotIn(Collection<Long> i) {       
        JPAQuery jpaQuery = getQueryFactory().createJPAQuery().from(QXXX.xxx).where(QXXX.xxx.id.notIn(i));       
        return jpaQuery.count();
    }

causes:

12:08:36,062 ERROR ErrorCounter:54 [main] - <AST>:0:0: unexpected AST node: {vector}
12:08:36,068 ERROR ErrorCounter:50 [main] - <AST>:0:0: unexpected AST node: {vector}
antlr.NoViableAltException: unexpected AST node: {vector}
    at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:2084) [hibernate-core-4.2.6.Final.jar:4.2.6.Final]
    at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:2051) [hibernate-core-4.2.6.Final.jar:4.2.6.Final]
    at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.whereClause(HqlSqlBaseWalker.java:794) [hibernate-core-4.2.6.Final.jar:4.2.6.Final]
    at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:595) [hibernate-core-4.2.6.Final.jar:4.2.6.Final]
    at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:299) [hibernate-core-4.2.6.Final.jar:4.2.6.Final]
    at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:247) [hibernate-core-4.2.6.Final.jar:4.2.6.Final]
    at org.hibernate.hql.internal.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:250) [hibernate-core-4.2.6.Final.jar:4.2.6.Final]
    at org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:185) [hibernate-core-4.2.6.Final.jar:4.2.6.Final]
    at org.hibernate.hql.internal.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:138) [hibernate-core-4.2.6.Final.jar:4.2.6.Final]
    at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:105) [hibernate-core-4.2.6.Final.jar:4.2.6.Final]
    at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:80) [hibernate-core-4.2.6.Final.jar:4.2.6.Final]
    at org.hibernate.engine.query.spi.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:168) [hibernate-core-4.2.6.Final.jar:4.2.6.Final]
    at org.hibernate.internal.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:221) [hibernate-core-4.2.6.Final.jar:4.2.6.Final]
    at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1261) [hibernate-core-4.2.6.Final.jar:4.2.6.Final]
    at org.hibernate.internal.QueryImpl.list(QueryImpl.java:101) [hibernate-core-4.2.6.Final.jar:4.2.6.Final]
    at org.hibernate.ejb.QueryImpl.getSingleResult(QueryImpl.java:287) [hibernate-entitymanager-4.2.6.Final.jar:4.2.6.Final]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.7.0_25]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[na:1.7.0_25]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.7.0_25]
    at java.lang.reflect.Method.invoke(Method.java:606) ~[na:1.7.0_25]
    at org.springframework.orm.jpa.SharedEntityManagerCreator$DeferredQueryInvocationHandler.invoke(SharedEntityManagerCreator.java:311) [spring-orm-3.2.4.RELEASE.jar:3.2.4.RELEASE]
    at com.sun.proxy.$Proxy35.getSingleResult(Unknown Source) [na:na]
    at com.mysema.query.jpa.impl.AbstractJPAQuery.count(AbstractJPAQuery.java:84) [querydsl-jpa-3.2.3.jar:na]
[...]
@0xlee
Copy link
Author

@0xlee 0xlee commented Oct 8, 2013

Thanks, that's the same Exception I've got.

@timowest
Copy link
Member

@timowest timowest commented Oct 8, 2013

Could you confirm whether the given collection is empty?

@buechele
Copy link

@buechele buechele commented Oct 8, 2013

The given Collection is not empty. It contains 2 elements in my testcase.

With an empty collection I got:

15:36:00,504 ERROR ErrorCounter:54 [main] - line 3:26: unexpected token: )
15:36:00,510 ERROR ErrorCounter:50 [main] - line 3:26: unexpected token: )
antlr.NoViableAltException: unexpected token: )
    at org.hibernate.hql.internal.antlr.HqlBaseParser.compoundExpr(HqlBaseParser.java:3104) [hibernate-core-4.2.6.Final.jar:4.2.6.Final]
    at org.hibernate.hql.internal.antlr.HqlBaseParser.inList(HqlBaseParser.java:2884) [hibernate-core-4.2.6.Final.jar:4.2.6.Final]
[...]

The first exception antlr.NoViableAltException: unexpected AST node: {vector} only occurs if you have more than one element in the collection.

@filipkokorevs
Copy link

@filipkokorevs filipkokorevs commented Oct 8, 2013

I can reproduce the bug after upgrading to the version mentioned above.

timowest added a commit that referenced this issue Oct 8, 2013
timowest added a commit that referenced this issue Oct 8, 2013
@timowest
Copy link
Member

@timowest timowest commented Oct 9, 2013

Could you try again with the latest SNAPSHOT from here https://oss.sonatype.org/content/repositories/snapshots/

@0xlee
Copy link
Author

@0xlee 0xlee commented Oct 9, 2013

I did a test and it works. Thank you very much :)

@buechele
Copy link

@buechele buechele commented Oct 9, 2013

Yes, I have also tested it and it works now seamless.
I have used following SNAPSOT-dependencies for testing:
querydsl-jpa-3.2.4.BUILD-20131009.052743-4
querydsl-codegen-3.2.4.BUILD-20131009.051816-4
querydsl-core-3.2.4.BUILD-20131009.051620-5
querydsl-apt-3.2.4.BUILD-20131009.051942-4

@timowest
Copy link
Member

@timowest timowest commented Oct 20, 2013

Released in 3.2.4

@timowest timowest closed this Oct 20, 2013
@timowest timowest added this to the 3.2.4 milestone Apr 13, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants