openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kevin Sutter" <kwsut...@gmail.com>
Subject error message for native sql parameters
Date Wed, 17 Oct 2007 16:29:42 GMT
Hi,
One of our customers stumbled over this error message when parsing a
@NamedNativeQuery:

bad-param-name: The parameter name or position "{0}" passed to \
    execute() is not valid.  All map keys must be a declared parameter \
    name or a number matching the parameter position.

The @NamedNativeQuery was as follows:

@NamedNativeQuery(name="getStationKeyForUpdate",
        query="SELECT * from KEYGEN where KEYNAME = :keyname FOR UPDATE")

Native Queries only allow positional parameters.  This customer thought that
the error message should be clearer since it mentions that named parameters
may also be allowed.

I looked at the code in question and we use the same processing for named
and positional parameter for both jpql and native queries.  So, it would be
overkill (in my mind) to separate out the processing just to clarify the
syntax requirements of the various queries.

So, would there be any problem with just adding the following to the error
message:

bad-param-name: The parameter name or position "{0}" passed to \
    execute() is not valid.  All map keys must be a declared parameter \
    name or a number matching the parameter position.  Native queries \
    only allow positional parameters.

It clarifies the problem without introducing a lot of extra processing.

Kevin

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message