You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jdo-dev@db.apache.org by Marco หงุ่ยตระกูล-Schulze <Ma...@NightLabs.de> on 2010/04/07 22:09:33 UTC
Query.executeWithMap(...) should accept unused parameters
Hello *,
we're currently migrating to DataNucleus 2.1.0-m2-SNAPSHOT and hit an
exception when calling javax.jdo.Query.executeWithMap(Map params)
whenever not all parameters are used in the query. See this forum post
for more details:
<http://www.jpox.org/servlet/forum/viewthread_thread,6052>
I just took a look at the JDO javadoc and saw that it says there, the
declared parameters and the parameters passed to the execute method have
to match exactly:
<http://db.apache.org/jdo/api23/apidocs/javax/jdo/Query.html#executeWithMap%28java.util.Map%29>
IMHO this is a feature making the use of JDO with dynamic queries (and
implicit parameter declarations) more complicated than necessary. It
would be more developer-friendly, if it was legal to pass more
parameters than the ones actually used, because they don't harm and it
removes the need for additional tracking logic (which parameter is used,
which one isn't).
I therefore recommend to relax the rule from exact match to "super-set",
i.e. only these 2 requirements:
1) All declared parameters must exist in the params-map passed to the
method executeWithMap(...).
2) All types of the declared parameters must match the ones passed to
executeWithMap(...).
For downward compatibility, I recommend introducing an option that can
be passed to the PersistenceManagerFactory (in the properties). As a
first idea, I recommend: javax.jdo.option.QueryParameterExactMatch (with
values "true" and "false").
Thanks a lot for consideration!
Best regards, Marco :-)
Re: Query.executeWithMap(...) should accept unused parameters
Posted by Marco หงุ่ยตระกูล-Schulze <Ma...@NightLabs.de>.
On 04/08/2010 07:44 PM, Andy Jefferson wrote:
>> I have no objection to this proposal. I don't think we really need a
>> compatibility option, though. I can't think of a case where the user
>> is *depending* on an exception to be thrown that will suddenly fail
>> the application. TCK testing aside.
>>
> I have no objection to the change, BUT ...
>
>
>> It is very close to being too late for 2.3, unless you can get
>> DataNucleus committers to agree to the change.
>>
> ... we need JDO 2.3 to be released. Shorter release cycles are the only way
> forward. This change can wait til 2.4; the option to use that is already in DN
> 2.1 (so people have their workaround), and DN 2.0 is the RI for JDO 2.3.
>
Hello everyone,
thanks a lot for your quick and positive replies! Working with you is
really fun :-)
We (the JFire-team) have no objections against postponing this to JDO
2.4 as we can use it already now via the DataNucleus-Option
"datanucleus.query.checkUnusedParameters". Thus, we're already perfectly
happy that my proposed change makes it into JDO and both versions 2.3 or
2.4 are fine for us.
Best regards and have a nice week-end!
Marco :-)
Re: Query.executeWithMap(...) should accept unused parameters
Posted by Andy Jefferson <an...@datanucleus.org>.
> I have no objection to this proposal. I don't think we really need a
> compatibility option, though. I can't think of a case where the user
> is *depending* on an exception to be thrown that will suddenly fail
> the application. TCK testing aside.
I have no objection to the change, BUT ...
> It is very close to being too late for 2.3, unless you can get
> DataNucleus committers to agree to the change.
... we need JDO 2.3 to be released. Shorter release cycles are the only way
forward. This change can wait til 2.4; the option to use that is already in DN
2.1 (so people have their workaround), and DN 2.0 is the RI for JDO 2.3.
--
Andy
DataNucleus (http://www.datanucleus.org)
Re: Query.executeWithMap(...) should accept unused parameters
Posted by Craig L Russell <cr...@oracle.com>.
I have no objection to this proposal. I don't think we really need a
compatibility option, though. I can't think of a case where the user
is *depending* on an exception to be thrown that will suddenly fail
the application. TCK testing aside.
It is very close to being too late for 2.3, unless you can get
DataNucleus committers to agree to the change.
Craig
On Apr 8, 2010, at 8:07 AM, Matthew Adams wrote:
> This seems like an excellent suggestion to me. +1.
>
> 2010/4/7 Marco หงุ่ยตระกูล-Schulze
> <Ma...@nightlabs.de>:
>> Hello *,
>>
>> we're currently migrating to DataNucleus 2.1.0-m2-SNAPSHOT and hit an
>> exception when calling javax.jdo.Query.executeWithMap(Map params)
>> whenever not all parameters are used in the query. See this forum
>> post
>> for more details:
>>
>> <http://www.jpox.org/servlet/forum/viewthread_thread,6052>
>>
>>
>> I just took a look at the JDO javadoc and saw that it says there, the
>> declared parameters and the parameters passed to the execute method
>> have
>> to match exactly:
>>
>> <http://db.apache.org/jdo/api23/apidocs/javax/jdo/Query.html#executeWithMap%28java.util.Map%29
>> >
>>
>>
>> IMHO this is a feature making the use of JDO with dynamic queries
>> (and
>> implicit parameter declarations) more complicated than necessary. It
>> would be more developer-friendly, if it was legal to pass more
>> parameters than the ones actually used, because they don't harm and
>> it
>> removes the need for additional tracking logic (which parameter is
>> used,
>> which one isn't).
>>
>> I therefore recommend to relax the rule from exact match to "super-
>> set",
>> i.e. only these 2 requirements:
>>
>> 1) All declared parameters must exist in the params-map passed to the
>> method executeWithMap(...).
>> 2) All types of the declared parameters must match the ones passed to
>> executeWithMap(...).
>>
>> For downward compatibility, I recommend introducing an option that
>> can
>> be passed to the PersistenceManagerFactory (in the properties). As a
>> first idea, I recommend: javax.jdo.option.QueryParameterExactMatch
>> (with
>> values "true" and "false").
>>
>> Thanks a lot for consideration!
>>
>> Best regards, Marco :-)
>>
>>
>
>
>
> --
> mailto:matthew@matthewadams.me
> skype:matthewadams12
> yahoo:matthewadams
> aol:matthewadams12
> google-talk:matthewadams12@gmail.com
> msn:matthew@matthewadams.me
> http://matthewadams.me
> http://www.linkedin.com/in/matthewadams
Craig L Russell
Architect, Oracle
http://db.apache.org/jdo
408 276-5638 mailto:Craig.Russell@oracle.com
P.S. A good JDO? O, Gasp!
Re: Query.executeWithMap(...) should accept unused parameters
Posted by Matthew Adams <ma...@matthewadams.me>.
This seems like an excellent suggestion to me. +1.
2010/4/7 Marco หงุ่ยตระกูล-Schulze <Ma...@nightlabs.de>:
> Hello *,
>
> we're currently migrating to DataNucleus 2.1.0-m2-SNAPSHOT and hit an
> exception when calling javax.jdo.Query.executeWithMap(Map params)
> whenever not all parameters are used in the query. See this forum post
> for more details:
>
> <http://www.jpox.org/servlet/forum/viewthread_thread,6052>
>
>
> I just took a look at the JDO javadoc and saw that it says there, the
> declared parameters and the parameters passed to the execute method have
> to match exactly:
>
> <http://db.apache.org/jdo/api23/apidocs/javax/jdo/Query.html#executeWithMap%28java.util.Map%29>
>
>
> IMHO this is a feature making the use of JDO with dynamic queries (and
> implicit parameter declarations) more complicated than necessary. It
> would be more developer-friendly, if it was legal to pass more
> parameters than the ones actually used, because they don't harm and it
> removes the need for additional tracking logic (which parameter is used,
> which one isn't).
>
> I therefore recommend to relax the rule from exact match to "super-set",
> i.e. only these 2 requirements:
>
> 1) All declared parameters must exist in the params-map passed to the
> method executeWithMap(...).
> 2) All types of the declared parameters must match the ones passed to
> executeWithMap(...).
>
> For downward compatibility, I recommend introducing an option that can
> be passed to the PersistenceManagerFactory (in the properties). As a
> first idea, I recommend: javax.jdo.option.QueryParameterExactMatch (with
> values "true" and "false").
>
> Thanks a lot for consideration!
>
> Best regards, Marco :-)
>
>
--
mailto:matthew@matthewadams.me
skype:matthewadams12
yahoo:matthewadams
aol:matthewadams12
google-talk:matthewadams12@gmail.com
msn:matthew@matthewadams.me
http://matthewadams.me
http://www.linkedin.com/in/matthewadams