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


Quick Go »

No member browsing this thread
Thread Status: Active
Total posts in this thread: 14
Posts: 14   Pages: 2   [ Previous Page | 1 2 ]
[ Jump to Last Post ]
Post new Thread
Author
Previous Thread This topic has been viewed 2522 times and has 13 replies Next Thread
Male erik
Expert
Member's Avatar

Belgium
Joined: Mar 12, 2004
Post Count: 2991
Status: Offline
Reply to this Post  Reply with Quote 
Re: Named Query

I agree with you. and also don't get why the FROM clause is there.

The namespace for queries has its boundaries in this package and super packages

from the spec

The file search order for a query scoped to class com.sun.nb.Bar is: META-INF/package.
jdo, WEB-INF/package.jdo, package.jdo, com/package.jdo, com/sun/package.jdo,
com/sun/nb/package.jdo, com/sun/nb/Bar.jdo
If the metadata is not found in the above, and there is a property in the PersistenceManagerFactory
javax.jdo.option.Mapping=mySQL, then the folowing files are searched:
META-INF/package-mySQL.orm, WEB-INF/package-mySQL.orm, packagemySQL.
orm, com/package-mySQL.orm, com/sun/package-mySQL.orm, com/sun/nb/
package-mySQL.orm, com/sun/nb/Bar-mySQL.orm.
If metadata is not found in the above, then the following files are searched: META-INF/
package.jdoquery, WEB-INF/package.jdoquery, package.jdoquery, com/package.
jdoquery, com/sun/package.jdoquery, com/sun/nb/package.jdoquery, com/sun/
nb/Bar.jdoquery.
----------------------------------------
Erik Bengtson


[Mar 19, 2005 5:52:54 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 andy
Expert
Member's Avatar

UK
Joined: Mar 13, 2004
Post Count: 5686
Status: Offline
Reply to this Post  Reply with Quote 
Re: Named Query

Still, it's not yet clear to me, what the first parameter of pm.newNamedQuery(...) is doing. Because if I write my <query/> within a <class/> element, the class is clear. If I don't, then I must declare a FROM xxx (do I?), so what's that parameter doing?

Well we weren't on the EG when that was decided so I can only guess. My assumption (and what JPOX assumes also) was that the class parameter to newNamedQuery() was used to determine the namespace of the query name. So if the user specifies a class then that named query "name" is in the namespace of that class ... and also the class name is subsitituted into the query (as we mentioned before). When the user doesnt provide a class to newNamedQuery() then the query is a "global" query, and the named query name is in the "global" namespace - and so the user has to specify the candidate class name directly in the query. The spec doesnt do what I would expect a spec to do ... that is, specify shock

And only to be sure: Did I understand it correctly then, that the name of the query must be unique within my whole project (no namespaces)?

See above for my interpretation of namespaces of named queries.
----------------------------------------
-Andy smile

----------------------------------------
[Edit 1 times, last edit by andy at Mar 19, 2005 6:23:58 PM]
[Mar 19, 2005 6:22:42 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 dinujohn
Newbie



India
Joined: May 31, 2010
Post Count: 2
Status: Offline
Reply to this Post  Reply with Quote 
Re: Named Query

Hi Andy

When the user doesnt provide a class to newNamedQuery() then the query is a "global" query, and the named query name is in the "global" namespace - and so the user has to specify the candidate class name directly in the query.


What should be the class name when we want the named query in global namespace ? Can i set the class name to null ?

newNamedQuery(null, query) ?

Thanks
-Dinu
[Jun 4, 2010 9:43:01 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 dinujohn
Newbie



India
Joined: May 31, 2010
Post Count: 2
Status: Offline
Reply to this Post  Reply with Quote 
Re: Named Query

Hi,

Has any one tried named query in global namespace, i.e not pertaining to any particular class ?

Thanks
Dinu John
[Jun 8, 2010 1:38: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 
Posts: 14   Pages: 2   [ Previous Page | 1 2 ]
[ Jump to Last Post ]
Show Printable Version of Thread  Post new Thread