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: 5
[ Jump to Last Post ]
Post new Thread
Author
Previous Thread This topic has been viewed 1476 times and has 4 replies Next Thread
Male andre
Newbie




Joined: Feb 28, 2005
Post Count: 12
Status: Offline
Reply to this Post  Reply with Quote 
sad navigational query through two level of collection

Hi,

I've some difficulties to write a navigational query through 2 level of collection. Could you please help me ?

schematically I have :



<class name="virtualdoc">
<field name="fieldsList">
<collection element-type="virtualField"/><join/>
</field>
</class>


<class name="virtualField">
<field name="name"/>
<field name="values">
<collection element-type="java.lang.String"/>
<join/>
</field>
</class>



I would like to retrieve all existing distinct values (across all virtualdocuments) for the virutalfields named "fieldname"

I've tried queries like this one :

Query aQuery = pm.newQuery(virtualdoc.class, "fieldsList.contains(aField) && aField.name =='fieldName' && aField.values.contains(aValue) && aValue.length()>0")
aQuery.declareImports("import virtual.*");
aQuery.declareVariables("virtual.virtualField aField; java.lang.String aValue");
aQuery.setResult("aValue");
aQuery.execute();


Any suggestions ? I suppose I should also add a grouping somewhere ...
[Aug 28, 2006 5:41:28 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 erik
Expert
Member's Avatar

Belgium
Joined: Mar 12, 2004
Post Count: 3114
Status: Offline
Reply to this Post  Reply with Quote 
Re: navigational query through two level of collection

what is wrong?
----------------------------------------
Erik Bengtson


[Aug 28, 2006 6:12:10 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: navigational query through two level of collection

with setResult("aValue") I receive the following error

javax.jdo.JDOUserException: Unable to find the field "aValue" in the candidate class. It is possible that this field is a field in a subclass, but it is illegal to reference fields directly when they are in a subclass.

If I don't add the setResult statement , I've the following result.
javax.jdo.JDODataStoreException: Error executing JDOQL query "SELECT 'ddMetaData.DDMetaDoc' AS JPOXMETADATA,`THIS_1`.`CHECKED_IN`,`THIS_1`.`CREATION_DATE`,`THIS_1`.`FAVORITE`,`THIS_1`.`INDEXED`,`
THIS_1`.`INHERIT_META_DATA`,`THIS_1`.`LANGUE`,`THIS_1`.`LAST_MODIFICATION_DATE`,`THIS_1`.`LOCKED`,`T
HIS_1`.`NAME`,`THIS_1`.`OBJ_ID`,`THIS_1`.`OUTLOOK_ID`,`THIS_1`.`TAILLE`,`THIS_1`.`TEMP` FROM `DDMETADOC` `THIS` LEFT OUTER JOIN `DDMETATYPEDEF` `THIS_METATEMPLATE_NAME` ON `THIS`.`META_TEMPLATE_OBJ_ID_OID` = `THIS_METATEMPLATE_NAME`.`OBJ_ID` INNER JOIN `DDOBJECT` `THIS_METATEMPLATE_NAME_1` ON `THIS_METATEMPLATE_NAME_1`.`OBJ_ID` = `THIS_METATEMPLATE_NAME`.`OBJ_ID` INNER JOIN `DDOBJECT` `THIS_1` ON `THIS_1`.`OBJ_ID` = `THIS`.`OBJ_ID` WHERE EXISTS (SELECT 1 FROM `DDMETADOC_MDOCFIELDSLIST` `THIS_MDOCFIELDSLIST_AFIELD` CROSS JOIN `DDMETAFIELD` `UNBOUND_AFIELD` WHERE EXISTS (SELECT 1 FROM `DDMETAFIELD_VALUES` `UNBOUND_AFIELD_VALUES_AVALUE` WHERE `UNBOUND_AFIELD_VALUES_AVALUE`.`OBJ_ID_OID` = `UNBOUND_AFIELD`.`OBJ_ID` AND `UNBOUND_AFIELD_VALUES_AVALUE`.`OBJ_ID_OID` = `UNBOUND_AFIELD`.`OBJ_ID` AND `THIS_MDOCFIELDSLIST_AFIELD`.`OBJ_ID_OID` = `THIS`.`OBJ_ID` AND `THIS_MDOCFIELDSLIST_AFIELD`.`OBJ_ID_OID` = `THIS`.`OBJ_ID` AND `UNBOUND_AFIELD`.`OBJ_ID` = `THIS_MDOCFIELDSLIST_AFIELD`.`OBJ_ID_EID` AND `THIS_METATEMPLATE_NAME_1`.`NAME` = ? AND `UNBOUND_AFIELD`.`NAME` = ?)) AND CHAR_LENGTH(`UNBOUND_AFIELD_VALUES_AVALUE`.`STRING_ELE`) > ?" : Unknown column 'UNBOUND_AFIELD_VALUES_AVALUE.STRING_ELE' in 'where clause'
java.sql.SQLException: Unknown column 'UNBOUND_AFIELD_VALUES_AVALUE.STRING_ELE' in 'where clause'

(You will notice I renamed some fields in my previous post to make my question more understandable.)
[Aug 28, 2006 6:39:09 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: navigational query through two level of collection

Are you using JPOX 1.1.1 ? Please make a test case and report a bug
----------------------------------------
Erik Bengtson


[Aug 28, 2006 8:23:14 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: navigational query through two level of collection

ok, posted a bug report with test case

http://www.jpox.org/servlet/jira/browse/CORE-2951

Thanks Erik
[Aug 28, 2006 9:51: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 
[ Jump to Last Post ]
Show Printable Version of Thread  Post new Thread