persistence@glassfish.java.net

RE: Exception if Query.setParameter call is missing

From: Mike Keith <michael.keith_at_oracle.com>
Date: Tue, 31 Jan 2006 11:05:34 -0500

I think it would be appropriate for an IllegalStateException to be
thrown in this case.

> -----Original Message-----
> From: Michael Bouschen [mailto:Michael.Bouschen_at_Sun.COM]
> Sent: Tuesday, January 31, 2006 10:48 AM
> To: Linda DeMichiel; Mike Keith
> Cc: persistence_at_glassfish.dev.java.net
> Subject: Exception if Query.setParameter call is missing
>
>
> Hi Linda, hi Mike,
>
> Shelly and I were discussing exceptions with running EJBQL
> queries using
> input parameters. The spec defines that an IllegalArgumentException is
> thrown if a parameter is specified that does not correspond to a
> parameter in the query string results in an IllegalArgumentException.
> What is the expected exception if the EJBQL uses a parameter, but its
> value is not defined on query execution, so the call
> Query.setParameter
> is missing:
> Query query = em.createQuery(
> "SELECT c FROM Customer c WHERE c.name = :name");
> List result = query.getResultList();
> I think method getResultList should indicate the error and throw an
> exception.
>
> Thanks!
>
> Regards Michael
>
>
>