{"action":"created","issue":{"url":"https://api.github.com/repos/impetus-opensource/Kundera/issues/824","labels_url":"https://api.github.com/repos/impetus-opensource/Kundera/issues/824/labels{/name}","comments_url":"https://api.github.com/repos/impetus-opensource/Kundera/issues/824/comments","events_url":"https://api.github.com/repos/impetus-opensource/Kundera/issues/824/events","html_url":"https://github.com/impetus-opensource/Kundera/issues/824","id":125103437,"number":824,"title":"JPQL: 'count' not working for mongodb and elasticsearch","user":{"login":"dreamingo88","id":8038178,"avatar_url":"https://avatars.githubusercontent.com/u/8038178?v=3","gravatar_id":"","url":"https://api.github.com/users/dreamingo88","html_url":"https://github.com/dreamingo88","followers_url":"https://api.github.com/users/dreamingo88/followers","following_url":"https://api.github.com/users/dreamingo88/following{/other_user}","gists_url":"https://api.github.com/users/dreamingo88/gists{/gist_id}","starred_url":"https://api.github.com/users/dreamingo88/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dreamingo88/subscriptions","organizations_url":"https://api.github.com/users/dreamingo88/orgs","repos_url":"https://api.github.com/users/dreamingo88/repos","events_url":"https://api.github.com/users/dreamingo88/events{/privacy}","received_events_url":"https://api.github.com/users/dreamingo88/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/impetus-opensource/Kundera/labels/Fixed","name":"Fixed","color":"009800"}],"state":"open","locked":false,"assignee":{"login":"devender-yadav","id":8894359,"avatar_url":"https://avatars.githubusercontent.com/u/8894359?v=3","gravatar_id":"","url":"https://api.github.com/users/devender-yadav","html_url":"https://github.com/devender-yadav","followers_url":"https://api.github.com/users/devender-yadav/followers","following_url":"https://api.github.com/users/devender-yadav/following{/other_user}","gists_url":"https://api.github.com/users/devender-yadav/gists{/gist_id}","starred_url":"https://api.github.com/users/devender-yadav/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/devender-yadav/subscriptions","organizations_url":"https://api.github.com/users/devender-yadav/orgs","repos_url":"https://api.github.com/users/devender-yadav/repos","events_url":"https://api.github.com/users/devender-yadav/events{/privacy}","received_events_url":"https://api.github.com/users/devender-yadav/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/impetus-opensource/Kundera/milestones/30","html_url":"https://github.com/impetus-opensource/Kundera/milestones/3.3","labels_url":"https://api.github.com/repos/impetus-opensource/Kundera/milestones/30/labels","id":1436772,"number":30,"title":"3.3","description":"For 3.3 release","creator":{"login":"chhavigangwal","id":5213632,"avatar_url":"https://avatars.githubusercontent.com/u/5213632?v=3","gravatar_id":"","url":"https://api.github.com/users/chhavigangwal","html_url":"https://github.com/chhavigangwal","followers_url":"https://api.github.com/users/chhavigangwal/followers","following_url":"https://api.github.com/users/chhavigangwal/following{/other_user}","gists_url":"https://api.github.com/users/chhavigangwal/gists{/gist_id}","starred_url":"https://api.github.com/users/chhavigangwal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chhavigangwal/subscriptions","organizations_url":"https://api.github.com/users/chhavigangwal/orgs","repos_url":"https://api.github.com/users/chhavigangwal/repos","events_url":"https://api.github.com/users/chhavigangwal/events{/privacy}","received_events_url":"https://api.github.com/users/chhavigangwal/received_events","type":"User","site_admin":false},"open_issues":21,"closed_issues":1,"state":"open","created_at":"2015-12-01T07:08:40Z","updated_at":"2016-01-12T12:34:25Z","due_on":"2016-01-14T18:30:00Z","closed_at":null},"comments":10,"created_at":"2016-01-06T03:31:54Z","updated_at":"2016-01-12T12:45:19Z","closed_at":null,"body":"## 1. persistence.xml:\r\n\t\r\n    <persistence-unit name=\"MONGO_PU\">\r\n\t\t<provider>com.impetus.kundera.KunderaPersistence</provider>\r\n        <class>models.Category</class>\r\n\t\t<exclude-unlisted-classes>true</exclude-unlisted-classes>\r\n\t\t<properties>\r\n\t\t\t<property name=\"kundera.nodes\" value=\"localhost\" />\r\n\t\t\t<property name=\"kundera.port\" value=\"27017\" />\r\n\t\t\t<property name=\"kundera.keyspace\" value=\"xplayks\" />\r\n\t\t\t<property name=\"kundera.dialect\" value=\"mongodb\" />\r\n\t\t\t<property name=\"kundera.client.lookup.class\" value=\"com.impetus.client.mongodb.MongoDBClientFactory\" />\r\n\t\t\t<property name=\"kundera.ddl.auto.prepare\" value=\"update\" />\r\n            <property name=\"kundera.show.query\" value=\"true\" />\r\n\t\t\t\r\n\t\t\t<property name=\"kundera.indexer.class\" value=\"com.impetus.client.es.index.ESIndexer\" />\r\n\t\t</properties>\r\n\t</persistence-unit>\r\n\r\n    <persistence-unit name=\"MONGO_NTV\">\r\n        <provider>com.impetus.kundera.KunderaPersistence</provider>\r\n        <class>models.Category</class>\r\n        <exclude-unlisted-classes>true</exclude-unlisted-classes>\r\n        <properties>\r\n            <property name=\"kundera.nodes\" value=\"localhost\" />\r\n            <property name=\"kundera.port\" value=\"27017\" />\r\n            <property name=\"kundera.keyspace\" value=\"xplayks\" />\r\n            <property name=\"kundera.dialect\" value=\"mongodb\" />\r\n            <property name=\"kundera.client.lookup.class\" value=\"com.impetus.client.mongodb.MongoDBClientFactory\" />\r\n            <property name=\"kundera.ddl.auto.prepare\" value=\"update\" />\r\n            <property name=\"kundera.show.query\" value=\"true\" />\r\n        </properties>\r\n    </persistence-unit>\r\n\t\r\n\r\n## 2. Category.java:\r\n\r\n\r\n    @Id\r\n    @Column(name=\"id\")\r\n    public String id;\r\n\t\r\n\t@Column(name=\"name\")\r\n\tpublic String name;\r\n\r\n\t@Column(name=\"code\")\r\n\tpublic String code;\r\n\r\n\t@Column(name=\"description\")\r\n\tpublic String description;'\r\n\t\r\n\r\n## 3. createCategory() using MONGO_PU:\r\n\r\n\tfor(int i = 9000; i < 9030; i++) {\r\n\t\tCategory ctg = new Category();\r\n\t\tctg.name = \"just a simple demo \" + i;\r\n\t\tctg.code = \"democode\";\r\n\t\tctg.description = \"just a demo, using mongodb and elasticsearch\";\r\n\r\n\t\tem.persist(ctg);\r\n\t}\r\n\t\r\n\t\r\n## 4. findCategory() using MONGO_PU (it using elasticsearch to execute the queries  auto):\r\n\r\n\r\n\tQuery q = em.createQuery(\"select ctg.id, ctg.name, ctg.code from Category ctg where ctg.code = 'democode'\", Category.class);\r\n\tq.setFirstResult(0);\r\n\tq.setMaxResults(20);\r\n\tList<Category> ctgList = q.getResultList();\r\n\tSystem.out.println(\"=================\"+ctgList.size()); //print 20\r\n\t\r\n\tq.setFirstResult(20);\r\n\tq.setMaxResults(20);\r\n\tctgList = q.getResultList(); //the same list as above.\r\n\tSystem.out.println(\"=================\"+ctgList.size()); //print 20, the same result as above. the right value should be 10.\r\n\r\nQuestion 1:  i think q.setFirstResult(20) doesn't effective. why?\r\n\t\r\n    Query query = em.createQuery(\"select count(ctg) from Category ctg where ctg.code = 'democode'\");\r\n \tString count = query.getResultList().get(0).toString();\r\n\tSystem.out.println(\"=================\"+count); //print 336, it's very very strange. the right value should be 30\r\n\r\nQuestion 2: what's the problem?\r\n\t\r\n## 5. findCategory() using MONGO_NTV:\r\n\r\n\tQuery query = em.createQuery(\"select count(ctg) from Category ctg where ctg.code = 'democode'\");\r\n\tString count = query.getResultList().get(0).toString();\r\n\tSystem.out.println(\"=================\"+count); //print 'just a simple demo ...', it's very very strange, the right value should be 30, \r\n\r\nQuestion 3: what's the problem? 'count' not supported by mongodb?\r\n"},"comment":{"url":"https://api.github.com/repos/impetus-opensource/Kundera/issues/comments/170900955","html_url":"https://github.com/impetus-opensource/Kundera/issues/824#issuecomment-170900955","issue_url":"https://api.github.com/repos/impetus-opensource/Kundera/issues/824","id":170900955,"user":{"login":"chhavigangwal","id":5213632,"avatar_url":"https://avatars.githubusercontent.com/u/5213632?v=3","gravatar_id":"","url":"https://api.github.com/users/chhavigangwal","html_url":"https://github.com/chhavigangwal","followers_url":"https://api.github.com/users/chhavigangwal/followers","following_url":"https://api.github.com/users/chhavigangwal/following{/other_user}","gists_url":"https://api.github.com/users/chhavigangwal/gists{/gist_id}","starred_url":"https://api.github.com/users/chhavigangwal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chhavigangwal/subscriptions","organizations_url":"https://api.github.com/users/chhavigangwal/orgs","repos_url":"https://api.github.com/users/chhavigangwal/repos","events_url":"https://api.github.com/users/chhavigangwal/events{/privacy}","received_events_url":"https://api.github.com/users/chhavigangwal/received_events","type":"User","site_admin":false},"created_at":"2016-01-12T12:45:19Z","updated_at":"2016-01-12T12:45:19Z","body":"@dreamingo88 \r\n\r\nA fix for adhoc querying via Elastic search is added , you can test the same by building our current trunk code. The same will be released with 3.3.\r\n\r\nChhavi"}}