{"action":"created","issue":{"url":"https://api.github.com/repos/querydsl/querydsl/issues/1982","repository_url":"https://api.github.com/repos/querydsl/querydsl","labels_url":"https://api.github.com/repos/querydsl/querydsl/issues/1982/labels{/name}","comments_url":"https://api.github.com/repos/querydsl/querydsl/issues/1982/comments","events_url":"https://api.github.com/repos/querydsl/querydsl/issues/1982/events","html_url":"https://github.com/querydsl/querydsl/issues/1982","id":169401719,"number":1982,"title":"null check for joined entity not working","user":{"login":"Kernle32DLL","id":1338408,"avatar_url":"https://avatars.githubusercontent.com/u/1338408?v=3","gravatar_id":"","url":"https://api.github.com/users/Kernle32DLL","html_url":"https://github.com/Kernle32DLL","followers_url":"https://api.github.com/users/Kernle32DLL/followers","following_url":"https://api.github.com/users/Kernle32DLL/following{/other_user}","gists_url":"https://api.github.com/users/Kernle32DLL/gists{/gist_id}","starred_url":"https://api.github.com/users/Kernle32DLL/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Kernle32DLL/subscriptions","organizations_url":"https://api.github.com/users/Kernle32DLL/orgs","repos_url":"https://api.github.com/users/Kernle32DLL/repos","events_url":"https://api.github.com/users/Kernle32DLL/events{/privacy}","received_events_url":"https://api.github.com/users/Kernle32DLL/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/querydsl/querydsl/labels/resolved","name":"resolved","color":"f7c6c7"}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":15,"created_at":"2016-08-04T15:23:14Z","updated_at":"2016-10-11T13:53:40Z","closed_at":"2016-10-11T00:17:13Z","body":"Hi there,\r\n\r\nwe encountered a strange problem while performing null checks with QueryDSL 3.7.4. Boiled down to its simplest form, we build a query like this:\r\n\r\n```Java\r\nJPAQuery testQuery = new JPAQuery(em);\r\ntestQuery.from(QPerson.person);\r\ntestQuery.where(QPerson.person.radiationExposedPerson.isNotNull());\r\n```\r\n\r\nWhich yields the following JPQL query:\r\n\r\n```SQL\r\nselect person\r\nfrom person person\r\nwhere person.radiationExposedPerson is not null\r\n```\r\n\r\nThe Java classes are (condensed) like this:\r\n\r\n```Java\r\n@Entity(name = \"person\")\r\npublic class Person {\r\n\r\n...\r\n\r\n@OneToOne(mappedBy= \"person\", optional = true)\r\nprivate RadiationExposedPerson radiationExposedPerson;\r\n\r\n...\r\n\r\n}\r\n\r\n@Entity(name = \"radiationexposedperson\")\r\npublic class RadiationExposedPerson  {\r\n\r\n...\r\n\r\n@OneToOne\r\nprivate Person person;\r\n\r\n...\r\n\r\n}\r\n```\r\n\r\nradiationExposedPerson is a mapped attribute in Person, and can be null. RadiationExposedPerson \"owns\" the one-to-one association to a Person (this makes sense in our case - keep in mind that this is a condensed version for the problem at hand). We were however not able to verify if this impacts the issue.\r\n\r\nThe expected output of the query above would be to show all persons, in which the radiationExposedPerson is not null. However, this does not work, and returns **all elements**. When the same query is modified to a \"isNull\" check, an **empty result** is returned. We verified that our database contains persons where radiationExposedPerson is null, and others where it is set.\r\n\r\nAnother thing. If the null check is used as an expression for ordering, we run into an AST Exception from hibernate:\r\n\r\n```Java\r\nJPAQuery testQuery = new JPAQuery(em);\r\ntestQuery.from(QPerson.person);\r\ntestQuery.orderBy(new OrderSpecifier<>(Order.ASC, QPerson.person.radiationExposedPerson.isNotNull()));\r\n```\r\n```SQL\r\nselect person\r\nfrom person person\r\norder by person.radiationExposedPerson is not null asc\r\n```\r\n```\r\norg.hibernate.hql.internal.ast.QuerySyntaxException: unexpected AST node: is not null [select person\r\nfrom de.com.steep.radoclid2.model.entities.Person person\r\norder by person.radiationExposedPerson is not null asc]\r\n\tat org.hibernate.hql.internal.ast.QuerySyntaxException.convert(QuerySyntaxException.java:91)\r\n\tat org.hibernate.hql.internal.ast.ErrorCounter.throwQueryException(ErrorCounter.java:109)\r\n\tat org.hibernate.hql.internal.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:284)\r\n\tat org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:206)\r\n\tat org.hibernate.hql.internal.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:158)\r\n\tat org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:131)\r\n\tat org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:93)\r\n\tat org.hibernate.engine.query.spi.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:167)\r\n\tat org.hibernate.internal.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:301)\r\n\tat org.hibernate.internal.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:236)\r\n\tat org.hibernate.internal.SessionImpl.createQuery(SessionImpl.java:1836)\r\n\tat org.hibernate.jpa.spi.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:328)\r\n\tat sun.reflect.GeneratedMethodAccessor100.invoke(Unknown Source)\r\n\tat sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\r\n\tat java.lang.reflect.Method.invoke(Method.java:497)\r\n\tat org.springframework.orm.jpa.ExtendedEntityManagerCreator$ExtendedEntityManagerInvocationHandler.invoke(ExtendedEntityManagerCreator.java:344)\r\n\tat com.sun.proxy.$Proxy144.createQuery(Unknown Source)\r\n\tat sun.reflect.GeneratedMethodAccessor100.invoke(Unknown Source)\r\n\tat sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\r\n\tat java.lang.reflect.Method.invoke(Method.java:497)\r\n\tat org.springframework.orm.jpa.SharedEntityManagerCreator$SharedEntityManagerInvocationHandler.invoke(SharedEntityManagerCreator.java:294)\r\n\tat com.sun.proxy.$Proxy144.createQuery(Unknown Source)\r\n\tat com.mysema.query.jpa.impl.AbstractJPAQuery.createQuery(AbstractJPAQuery.java:129)\r\n\tat com.mysema.query.jpa.impl.AbstractJPAQuery.createQuery(AbstractJPAQuery.java:96)\r\n\tat com.mysema.query.jpa.impl.AbstractJPAQuery.list(AbstractJPAQuery.java:248)\r\n\tat de.com.steep.radoclid2.application.ui.web.mvc.controller.IndexController.index(IndexController.java:105)\r\n\tat de.com.steep.radoclid2.application.ui.web.mvc.controller.IndexController$$FastClassBySpringCGLIB$$76d43e53.invoke(<generated>)\r\n\tat org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)\r\n\tat org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:720)\r\n\tat org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)\r\n\tat org.springframework.aop.interceptor.AbstractTraceInterceptor.invoke(AbstractTraceInterceptor.java:115)\r\n\tat org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)\r\n\tat org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)\r\n\tat org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)\r\n\tat org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:655)\r\n\tat de.com.steep.radoclid2.application.ui.web.mvc.controller.IndexController$$EnhancerBySpringCGLIB$$bd210a5b.index(<generated>)\r\n\tat sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\r\n\tat sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)\r\n\tat sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\r\n\tat java.lang.reflect.Method.invoke(Method.java:497)\r\n\tat org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:221)\r\n\tat org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:136)\r\n\tat org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:110)\r\n\tat org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:817)\r\n\tat org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:731)\r\n\tat org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)\r\n\tat org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:959)\r\n\tat org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893)\r\n\tat org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:968)\r\n\tat org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:859)\r\n\tat javax.servlet.http.HttpServlet.service(HttpServlet.java:622)\r\n\tat org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:844)\r\n\tat javax.servlet.http.HttpServlet.service(HttpServlet.java:729)\r\n\tat org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292)\r\n\tat org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)\r\n\tat org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)\r\n\tat org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)\r\n\tat org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)\r\n\tat org.springframework.boot.actuate.autoconfigure.EndpointWebMvcAutoConfiguration$ApplicationContextHeaderFilter.doFilterInternal(EndpointWebMvcAutoConfiguration.java:237)\r\n\tat org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)\r\n\tat org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)\r\n\tat org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)\r\n\tat de.com.steep.radoclid2.application.filter.HeaderManipulationFilter.doFilter(HeaderManipulationFilter.java:58)\r\n\tat org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)\r\n\tat org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)\r\n\tat org.springframework.boot.actuate.trace.WebRequestTraceFilter.doFilterInternal(WebRequestTraceFilter.java:112)\r\n\tat org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)\r\n\tat org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)\r\n\tat org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)\r\n\tat org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:316)\r\n\tat org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:126)\r\n\tat org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:90)\r\n\tat org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)\r\n\tat org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:114)\r\n\tat org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)\r\n\tat org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:122)\r\n\tat org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)\r\n\tat org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111)\r\n\tat org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)\r\n\tat org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:169)\r\n\tat org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)\r\n\tat org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:48)\r\n\tat org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)\r\n\tat org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:205)\r\n\tat org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)\r\n\tat org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:120)\r\n\tat org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)\r\n\tat org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:64)\r\n\tat org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)\r\n\tat org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)\r\n\tat org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:91)\r\n\tat org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)\r\n\tat org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:53)\r\n\tat org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)\r\n\tat org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)\r\n\tat de.com.steep.radoclid2.application.filter.HeaderManipulationFilter.doFilter(HeaderManipulationFilter.java:58)\r\n\tat org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)\r\n\tat org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:213)\r\n\tat org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:176)\r\n\tat org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)\r\n\tat org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:262)\r\n\tat org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)\r\n\tat org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)\r\n\tat org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99)\r\n\tat org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)\r\n\tat org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)\r\n\tat org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)\r\n\tat org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:121)\r\n\tat org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)\r\n\tat org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)\r\n\tat org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)\r\n\tat org.springframework.boot.actuate.autoconfigure.MetricsFilter.doFilterInternal(MetricsFilter.java:103)\r\n\tat org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)\r\n\tat org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)\r\n\tat org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)\r\n\tat org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212)\r\n\tat org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)\r\n\tat org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:614)\r\n\tat org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)\r\n\tat org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)\r\n\tat org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)\r\n\tat org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:522)\r\n\tat org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1095)\r\n\tat org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:672)\r\n\tat org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1500)\r\n\tat org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1456)\r\n\tat java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)\r\n\tat java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)\r\n\tat org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)\r\n\tat java.lang.Thread.run(Thread.java:745)\r\n\r\n```\r\n\r\nI gonna admit, this looks like valid JPQL, but I'm no expert here. If this is indeed correct, I might need to investigate the hibernate side of things."},"comment":{"url":"https://api.github.com/repos/querydsl/querydsl/issues/comments/252923199","html_url":"https://github.com/querydsl/querydsl/issues/1982#issuecomment-252923199","issue_url":"https://api.github.com/repos/querydsl/querydsl/issues/1982","id":252923199,"user":{"login":"Shredder121","id":4105066,"avatar_url":"https://avatars.githubusercontent.com/u/4105066?v=3","gravatar_id":"","url":"https://api.github.com/users/Shredder121","html_url":"https://github.com/Shredder121","followers_url":"https://api.github.com/users/Shredder121/followers","following_url":"https://api.github.com/users/Shredder121/following{/other_user}","gists_url":"https://api.github.com/users/Shredder121/gists{/gist_id}","starred_url":"https://api.github.com/users/Shredder121/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Shredder121/subscriptions","organizations_url":"https://api.github.com/users/Shredder121/orgs","repos_url":"https://api.github.com/users/Shredder121/repos","events_url":"https://api.github.com/users/Shredder121/events{/privacy}","received_events_url":"https://api.github.com/users/Shredder121/received_events","type":"User","site_admin":false},"created_at":"2016-10-11T13:53:40Z","updated_at":"2016-10-11T13:53:40Z","body":"Oh, good to hear that you have it resolved."}}
{"actor":{"display_login":"Shredder121"}}