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   [ 1 2 | Next Page ]
[ Jump to Last Post ]
Post new Thread
Author
Previous Thread This topic has been viewed 2523 times and has 13 replies Next Thread
Male ericmacau
Novice




Joined: May 19, 2004
Post Count: 46
Status: Offline
Reply to this Post  Reply with Quote 
Named Query

Hello,

How can I define Named-Query through XDoclet ?

Eric
[Mar 16, 2005 3:36:07 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 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

How can I define Named-Query through XDoclet ?

Ask on the XDoclet mailing list maybe since it is nothing to do with JPOX.
----------------------------------------
-Andy smile

[Mar 16, 2005 6:39:01 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 nlmarco
Expert
Member's Avatar

Germany
Joined: Mar 15, 2004
Post Count: 766
Status: Offline
Reply to this Post  Reply with Quote 
Re: Named Query

Hello Andy,

I'm currently implementing XDoclet support for @jdo.query, but I wonder why the attribute name is defined as #IMPLIED in the DTD instead of #REQUIRED. What is the default name if I omit the declaration? Or is this an error in the DTD?

I guess, language defaults to javax.jdo.query.JDOQL if omitted, right?

Is it correct, that language can be one of the following values (and nothing different)?

  • javax.jdo.query.JDOQL
  • javax.jdo.query.SQL
  • javax.jdo.query.JPOXSQL


Marco smile
----------------------------------------
Best regards, Marco smile
jfire: free erp, crm, scm and more
[Mar 19, 2005 3:20:27 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 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

I'm currently implementing XDoclet support for @jdo.query,

Excellent.
but I wonder why the attribute name is defined as #IMPLIED in the DTD instead of #REQUIRED. What is the default name if I omit the declaration? Or is this an error in the DTD?

I'd expect it to be REQUIRED, 'cos a named query without a name is as much use as a chocolate teapot biggrin
I guess, language defaults to javax.jdo.query.JDOQL if omitted, right?

Yes.
Is it correct, that language can be one of the following values (and nothing different)?

  • javax.jdo.query.JDOQL
  • javax.jdo.query.SQL
  • javax.jdo.query.JPOXSQL

The JDO2 supported values are javax.jdo.query.JDOQL and javax.jdo.query.SQL. JPOX also supports "javax.jdo.query.JPOXSQL". But you should allow people to put in what they want and then if we add OQL or HQL or something else in the future then it is accepted.
----------------------------------------
-Andy smile

[Mar 19, 2005 3:24:57 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 nlmarco
Expert
Member's Avatar

Germany
Joined: Mar 15, 2004
Post Count: 766
Status: Offline
Reply to this Post  Reply with Quote 
Re: Named Query

I'd expect it to be REQUIRED, 'cos a named query without a name is as much use as a chocolate teapot biggrin

You're right - I've made it required in XDoclet.

But you should allow people to put in what they want

OK. I won't check and only add the possible values to the documentation. So, people have to search for their typos themselves wink

A query tag now looks like this:
@jdo.query
name="MyQuery"
language="javax.jdo.query.JDOQL"
expression="SELECT FROM org.jpox.example.Product WHERE status == 'Sold Out'"


If you agree with the param "expression", I'll check it in to XDoclet-CVS... Or any better naming idea for the query itself? Maybe "text" or "query"? It's shorter...

Marco smile
----------------------------------------
Best regards, Marco smile
jfire: free erp, crm, scm and more
[Mar 19, 2005 3:39:23 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 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

A query tag now looks like this:
@jdo.query
name="MyQuery"
language="javax.jdo.query.JDOQL"
expression="SELECT FROM org.jpox.example.Product WHERE status == 'Sold Out'"

If you agree with the param "expression", I'll check it in to XDoclet-CVS...

The JDO spec doesn't provide a name, and "expression" sounds fine to me
----------------------------------------
-Andy smile

[Mar 19, 2005 3:53:47 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: 2991
Status: Offline
Reply to this Post  Reply with Quote 
Re: Named Query

From the latest discussion in EG, I expect that the operation
pm.newQuery(Class cls,String filter) will be renamed to
pm.newQuery(Class cls,String query), so maybe it's better use query instead of expression
----------------------------------------
Erik Bengtson


[Mar 19, 2005 4:16:51 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 nlmarco
Expert
Member's Avatar

Germany
Joined: Mar 15, 2004
Post Count: 766
Status: Offline
Reply to this Post  Reply with Quote 
Re: Named Query

Hello!

OK, I've renamed "expression" to "query" (is shorter anyway). Therefore, an example tag looks now like this:
@jdo.query
name="MyNamedQuery"
language="javax.jdo.query.JDOQL"
query="SELECT
FROM org.jpox.example.Product WHERE status == paramStatus
PARAMETERS String paramStatus
IMPORTS import java.lang.String
"
I've committed my changes to the XDoclet CVS and for those who don't want to compile it themselves, the jar is available here.

I've still some questions:

  • Why is the query defined within a class (according to the DTD query is a child element of class)? Does that mean, the declared name is within a namespace?
  • Why do I have to declare a "FROM"? When I obtain the query via pm.newNamedQuery(Class clazz, String queryName), I define the class already... What happens, if these two classes differ? Or is the first parameter of newNamedQuery the namespace?
  • Is it a minor bug in JPOX that I need to use fully qualified class names in the query expression (short name in FROM clause failed) or is it required by the spec?

Best regards, Marco smile
----------------------------------------
Best regards, Marco smile
jfire: free erp, crm, scm and more
----------------------------------------
[Edit 2 times, last edit by nlmarco at Mar 19, 2005 5:16:56 PM]
[Mar 19, 2005 5:13:45 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 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

Why is the query defined within a class (according to the DTD query is a child element of class)? Does that mean, the declared name is within a namespace?

It is defined EITHER for a class or within a file. If within a class the query doesnt need to include the candidate class name.

Why do I have to declare a "FROM"? When I obtain the query via pm.newNamedQuery(Class clazz, String queryName), I define the class already... What happens, if these two classes differ? Or is the first parameter of newNamedQuery the namespace?

See above. You dont have to define the candidate class when you define your query within a <class>
Is it a minor bug in JPOX that I need to use fully qualified class names in the query expression (short name in FROM clause failed) or is it required by the spec?

The query expression has to have the fully qualified class because otherwise how would JPOX know where the class is from ? See above regarding specifying named queries in <class>
----------------------------------------
-Andy smile

[Mar 19, 2005 5:20:28 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 nlmarco
Expert
Member's Avatar

Germany
Joined: Mar 15, 2004
Post Count: 766
Status: Offline
Reply to this Post  Reply with Quote 
Re: Named Query

Hello Andy,

thanks for the info! Seems, I overlooked the possibility that "query" can be a child element of "jdo" directly.

@Andy & Erik:
Well, concerning XDoclet, I've a little problem then: In XDoclet, all tags are written into a java-file and therefore attached to a class. Hence, if I use only the tag @jdo.query, I can't know whether this query should be global or relative within the current class. To solve this, there are two possibilities: Either I use two different tags - e.g. @jdo.classquery and @jdo.globalquery - or I use an optional parameter global="yes|no". I prefer the latter version and I would default global to no (because this is probably more common). What do you think?

BTW: I've tried to omit the FROM xxx and it works fine! Thanks for this hint! Makes life much easier.

edit:
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?

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)?
----------------------------------------
Best regards, Marco smile
jfire: free erp, crm, scm and more
----------------------------------------
[Edit 2 times, last edit by nlmarco at Mar 19, 2005 5:41:13 PM]
[Mar 19, 2005 5:36: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 
Posts: 14   Pages: 2   [ 1 2 | Next Page ]
[ Jump to Last Post ]
Show Printable Version of Thread  Post new Thread