Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-dev] createNamedQuery("non-existing")

My vote is to throw IllegalArgumentException when calling createNamedQuery with null, but to make the change in the trunk stream so it will not be introduced in a patch.


Goerler, Adrian wrote:
I am just having a look at the em.createNamedQuery method invoked with nasty parameters. If I am invoking em.createNamedQuery with a non-existing query name, I am getting a query that throws an IllegalArgumentException upon execution. If I am invoking it with null, I am getting an query that throws a NPE upon execution.
But the IllegalArgumentException is not thrown immediately.
The API states * *@throws* IllegalArgumentException if a query has not been
     *         defined with the given name or if the query string is
     *         found to be invalid
    *public* Query createNamedQuery(String name);
So we could throw an IllegalArgumentException in both cases. However, doing so would strictly be incompatible as there might be coding out there that creates illegal named queries but never executes them. What do you think? Should we do something about this or leave it as it is? -Adrian


eclipselink-dev mailing list

Back to the top