db-jdo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marco หงุ่ยตระกูล-Schulze <Ma...@NightLabs.de>
Subject Query.executeWithMap(...) should accept unused parameters
Date Wed, 07 Apr 2010 20:09:33 GMT
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 :-)


Mime
View raw message