Welcome Guest  |  Register  |  Login
Login Name Password
  Search  
  Index  | Recent Threads  | Unanswered Threads  | Who's Online  | User List  | Help


Quick Go »

No member browsing this thread
Thread Status: Active
Total posts in this thread: 8
[ Jump to Last Post ]
Post new Thread
Author
Previous Thread This topic has been viewed 800 times and has 7 replies Next Thread
Male andre
Newbie




Joined: Feb 28, 2005
Post Count: 12
Status: Offline
Reply to this Post  Reply with Quote 
query evaluation with OR operator

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.
[Sep 6, 2006 12:31:24 PM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
Male erik
Expert
Member's Avatar

Belgium
Joined: Mar 12, 2004
Post Count: 3114
Status: Offline
Reply to this Post  Reply with Quote 
Re: query evaluation with OR operator

can you enable log in debug mode and post the generated query here?
----------------------------------------
Erik Bengtson


[Sep 6, 2006 7:04:53 PM] Show Printable Version of Post    View Member Profile    Send Private Message    Hidden to Guest [Link] Report threatening or abusive post: please login first  Go to top 
Male andre
Newbie




Joined: Feb 28, 2005
Post Count: 12
Status: Offline
Reply to this Post  Reply with Quote 
Re: query evaluation with OR operator

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 sad

Thanks for your feedback !!!
[Sep 7, 2006 1:17:23 AM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
Male andre
Newbie




Joined: Feb 28, 2005
Post Count: 12
Status: Offline
Reply to this Post  Reply with Quote 
Re: query evaluation with OR operator

I tried to give the most simple and accurate description of the problem ... could you please have a look ?

Thanks
[Sep 15, 2006 7:46:04 PM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
Male erik
Expert
Member's Avatar

Belgium
Joined: Mar 12, 2004
Post Count: 3114
Status: Offline
Reply to this Post  Reply with Quote 
Re: query evaluation with OR operator

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


[Sep 15, 2006 8:09:20 PM] Show Printable Version of Post    View Member Profile    Send Private Message    Hidden to Guest [Link] Report threatening or abusive post: please login first  Go to top 
Male andre
Newbie




Joined: Feb 28, 2005
Post Count: 12
Status: Offline
Reply to this Post  Reply with Quote 
Re: query evaluation with OR operator

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.
[Sep 15, 2006 8:50:25 PM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
Male andre
Newbie




Joined: Feb 28, 2005
Post Count: 12
Status: Offline
Reply to this Post  Reply with Quote 
Re: query evaluation with OR operator

Should I conclude this is a bug ?
Is there any other suggestion ?

Thanks.
[Sep 26, 2006 11:05:08 PM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
Male erik
Expert
Member's Avatar

Belgium
Joined: Mar 12, 2004
Post Count: 3114
Status: Offline
Reply to this Post  Reply with Quote 
Re: query evaluation with OR operator

Query aQuery = pm.newQuery(Task.class, "(assignee==a || creator==c ) && c.name=='username1'");

aQuery.declareVariables("GenObject c");
----------------------------------------
Erik Bengtson


[Sep 27, 2006 11:04:36 AM] Show Printable Version of Post    View Member Profile    Send Private Message    Hidden to Guest [Link] Report threatening or abusive post: please login first  Go to top 
[ Jump to Last Post ]
Show Printable Version of Thread  Post new Thread