{"action":"created","issue":{"url":"https://api.github.com/repos/querydsl/querydsl/issues/1966","repository_url":"https://api.github.com/repos/querydsl/querydsl","labels_url":"https://api.github.com/repos/querydsl/querydsl/issues/1966/labels{/name}","comments_url":"https://api.github.com/repos/querydsl/querydsl/issues/1966/comments","events_url":"https://api.github.com/repos/querydsl/querydsl/issues/1966/events","html_url":"https://github.com/querydsl/querydsl/issues/1966","id":164900488,"number":1966,"title":"...ConstantImpl cannot be cast to ...Predicate","user":{"login":"hylkevds","id":4989461,"avatar_url":"https://avatars.githubusercontent.com/u/4989461?v=3","gravatar_id":"","url":"https://api.github.com/users/hylkevds","html_url":"https://github.com/hylkevds","followers_url":"https://api.github.com/users/hylkevds/followers","following_url":"https://api.github.com/users/hylkevds/following{/other_user}","gists_url":"https://api.github.com/users/hylkevds/gists{/gist_id}","starred_url":"https://api.github.com/users/hylkevds/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hylkevds/subscriptions","organizations_url":"https://api.github.com/users/hylkevds/orgs","repos_url":"https://api.github.com/users/hylkevds/repos","events_url":"https://api.github.com/users/hylkevds/events{/privacy}","received_events_url":"https://api.github.com/users/hylkevds/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/querydsl/querydsl/labels/resolved","name":"resolved","color":"f7c6c7"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-07-11T18:16:12Z","updated_at":"2016-07-13T16:39:21Z","closed_at":null,"body":"I'm trying to do some boolean logic with constants. To do this I've created a class:\r\n\r\n```\r\npublic static class ConstantBooleanExpression extends BooleanExpression {\r\n\r\n        public ConstantBooleanExpression(final Boolean constant) {\r\n            super(ConstantImpl.create(constant));\r\n        }\r\n\r\n        @Override\r\n        @Nullable\r\n        public <R, C> R accept(Visitor<R, C> v, C context) {\r\n            return v.visit((Constant<Boolean>) mixin, context);\r\n        }\r\n    }\r\n```\r\n\r\nHowever when I use this class by doing something like:\r\n\r\n```\r\nConstantBooleanExpression t = new ConstantBooleanExpression(Boolean.TRUE);\r\nConstantBooleanExpression f = new ConstantBooleanExpression(Boolean.FALSE);\r\nQTesttable qt = QTesttable.testtable;\r\nSQLQuery<Tuple> query = createQueryFactory()\r\n                .select(qt.id, qt.description)\r\n                .from(qt)\r\n                .where(t.or(f));\r\nquery.fetchFirst();\r\n```\r\n\r\nI get an exception: \r\n```\r\njava.lang.ClassCastException: com.querydsl.core.types.ConstantImpl cannot be cast to com.querydsl.core.types.Predicate\r\n\tat com.querydsl.core.types.dsl.BooleanExpression.or(BooleanExpression.java:105)\r\n```\r\n\r\nI've extended my test project that demonstrates the error:\r\nhttps://github.com/hylkevds/QueryDslTests\r\nIf you point it at an empty database (in pom.xml and src/main/resources/db.properties) it'll create a table with some data and run a unit test against it. For me that fails with the above mentioned exception.\r\n\r\nI'm guessing the two Boolean constants in ConstantImpl.Constants should also implement Predicate?\r\n"},"comment":{"url":"https://api.github.com/repos/querydsl/querydsl/issues/comments/232413208","html_url":"https://github.com/querydsl/querydsl/issues/1966#issuecomment-232413208","issue_url":"https://api.github.com/repos/querydsl/querydsl/issues/1966","id":232413208,"user":{"login":"timowest","id":574167,"avatar_url":"https://avatars.githubusercontent.com/u/574167?v=3","gravatar_id":"","url":"https://api.github.com/users/timowest","html_url":"https://github.com/timowest","followers_url":"https://api.github.com/users/timowest/followers","following_url":"https://api.github.com/users/timowest/following{/other_user}","gists_url":"https://api.github.com/users/timowest/gists{/gist_id}","starred_url":"https://api.github.com/users/timowest/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/timowest/subscriptions","organizations_url":"https://api.github.com/users/timowest/orgs","repos_url":"https://api.github.com/users/timowest/repos","events_url":"https://api.github.com/users/timowest/events{/privacy}","received_events_url":"https://api.github.com/users/timowest/received_events","type":"User","site_admin":false},"created_at":"2016-07-13T16:39:21Z","updated_at":"2016-07-13T16:39:21Z","body":"Expressions.TRUE and FALSE aren't constants, they are template expressions, they encode the values as serialized \"true\" and \"false\""}}
{"actor":{"display_login":"timowest"}}