![]() |
![]() |
|
| Index | Recent Threads | Unanswered Threads | Who's Online | User List | Help |
|
|
| No member browsing this thread |
|
Thread Status: Active Total posts in this thread: 8
|
|
| Author |
|
|
Newbie Joined: Feb 28, 2005 Post Count: 12 Status: Offline |
I don't know if my problem is due to my lack of JDO knowledge or to something else. What should be the result for a query with the following filter: (assignee.name== "assigneename") || (creator.name== "creatorname") In my test, candidates objects (task) with the field "assignee" not set (equal to null) are not returned in query results even if they satisfies the second part of the expression. (same with bitwise operator). Is it the normal behavior ? Thanks in advance for your remarks. |
||
|
|
Expert Belgium Joined: Mar 12, 2004 Post Count: 3114 Status: Offline |
can you enable log in debug mode and post the generated query here? ---------------------------------------- Erik Bengtson ![]() |
||
|
|
Newbie Joined: Feb 28, 2005 Post Count: 12 Status: Offline |
Ok, I investigated my problem further and isolated the problem from my development to give you a better view. I first tested with 2 simple classes task and user without any ancestor and in this case it works fine. Then, I add (like in my orignal app) GenObject as ancestor of "task" and "user" and in this case the problem arise. Metadatas for GenObject <jdo> <package name="org.jpox.test"> <class name="GenObject"> <field name="name" persistence-modifier="persistent"/> </class> </package> </jdo> Metadatas for Task <jdo> <package name="org.jpox.test"> <class name="Task" persistence-capable-superclass="org.jpox.test.GenObject" detachable="true" embedded-only="false" persistence-modifier="persistence-capable" requires-extent="true"> <inheritance strategy="new-table"> </inheritance> <field name="creator" persistence-modifier="persistent"/> <field name="assignee" persistence-modifier="persistent"/> </class> </package> </jdo> Metadata for user <jdo> <package name="org.jpox.test"> <class name="User" persistence-capable-superclass="org.jpox.test.GenObject" detachable="true" embedded-only="false" persistence-modifier="persistence-capable" requires-extent="true"> <inheritance strategy="new-table"> </inheritance> <field name="effort" persistence-modifier="persistent"/> </class> </package> </jdo> Code to persist 1 user and 2 tasks User aUser = new User(); aUser.setName("username1"); Task task1 = new Task(); task1.setAssignee(aUser); task1.setCreator(aUser); Task task2 = new Task(); task2.setCreator(aUser); pm.makePersistent(task1); pm.makePersistent(task2); pm.makePersistent(aUser); Query to retrieve these two tasks Query aQuery = pm.newQuery(Task.class, "(assignee.name=='username1') | (creator.name=='username1')"); Log generated in debug mode 02:51:28,010 (main) DEBUG [JPOX.Transaction] - Transaction begun with connection com.mysql.jdbc.Connection@1d86fd3 02:51:28,010 (main) DEBUG [JPOX.JDO.QUERY] - JDOQL Query : Precompiling "SELECT FROM org.jpox.test.Task WHERE (assignee.name=='username1') | (creator.name=='username1')" 02:51:28,010 (main) DEBUG [JPOX.JDO.QUERY] - JDOQL Query : "SELECT FROM org.jpox.test.Task WHERE (assignee.name=='username1') | (creator.name=='username1')" 02:51:28,042 (main) DEBUG [JPOX.General] - org.jpox.util.SoftValueMap(25378506) size = 0, hits = 0, misses = 1, cleared = 0 02:51:28,042 (main) DEBUG [JPOX.JDO.QUERY] - JDOQL Query : Compile Time = 32 ms 02:51:28,042 (main) DEBUG [JPOX.RDBMS.SQL] - SELECT 'org.jpox.test.Task' AS JPOXMETADATA,`THIS`.`TASK_ID`,`THIS_1`.`NAME` FROM `TASK` `THIS` LEFT OUTER JOIN `USER` `THIS_ASSIGNEE_NAME` ON `THIS`.`ASSIGNEE_USER_ID_OID` = `THIS_ASSIGNEE_NAME`.`USER_ID` INNER JOIN `GENOBJECT` `THIS_ASSIGNEE_NAME_1` ON `THIS_ASSIGNEE_NAME_1`.`GENOBJECT_ID` = `THIS_ASSIGNEE_NAME`.`USER_ID` LEFT OUTER JOIN `USER` `THIS_CREATOR_NAME` ON `THIS`.`CREATOR_USER_ID_OID` = `THIS_CREATOR_NAME`.`USER_ID` INNER JOIN `GENOBJECT` `THIS_CREATOR_NAME_1` ON `THIS_CREATOR_NAME_1`.`GENOBJECT_ID` = `THIS_CREATOR_NAME`.`USER_ID` INNER JOIN `GENOBJECT` `THIS_1` ON `THIS_1`.`GENOBJECT_ID` = `THIS`.`TASK_ID` WHERE (`THIS_ASSIGNEE_NAME_1`.`NAME` = <'username1'>) OR (`THIS_CREATOR_NAME_1`.`NAME` = <'username1'>) -- 2 PS parameters 02:51:28,042 (main) DEBUG [JPOX.RDBMS.SQL] - Execution Time = 0 ms 02:51:28,057 (main) DEBUG [JPOX.RDBMS] - Retrieved object with OID "1[OID]org.jpox.test.Task" Result : only one task Thanks for your feedback !!! |
||
|
|
Newbie Joined: Feb 28, 2005 Post Count: 12 Status: Offline |
I tried to give the most simple and accurate description of the problem ... could you please have a look ? Thanks |
||
|
|
Expert Belgium Joined: Mar 12, 2004 Post Count: 3114 Status: Offline |
Try this Query aQuery = pm.newQuery(Task.class, "(assigne==a &&& a.name=='username1') | (creator==c && c.name=='username1')"); aQuery.declareVariables("Assigne a; Creator c"); ---------------------------------------- Erik Bengtson ![]() |
||
|
|
Newbie Joined: Feb 28, 2005 Post Count: 12 Status: Offline |
I've tried this way (assignee and creator are objects of type User) Query aQuery = pm.newQuery(Task.class, "(assignee==a && a.name=='username1') | (creator==c && c.name=='username1')"); aQuery.declareVariables("User a; User c"); but I still get just one result. |
||
|
|
Newbie Joined: Feb 28, 2005 Post Count: 12 Status: Offline |
Should I conclude this is a bug ? Is there any other suggestion ? Thanks. |
||
|
|
Expert Belgium Joined: Mar 12, 2004 Post Count: 3114 Status: Offline |
Query aQuery = pm.newQuery(Task.class, "(assignee==a || creator==c ) && c.name=='username1'"); aQuery.declareVariables("GenObject c"); ---------------------------------------- Erik Bengtson ![]() |
||
|
|
|
|
|
Current timezone is GMT Mar 14, 2010 8:17:23 AM |