Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] named query + skip null parameters


Thanks for the answer,

I don't want any Hibernate or Eclipselink specific code, that is why I used named queries.

Or is there a way to dynamically build a query with JPA?

Leon


Tim Hollosy wrote:
I think you get no results because column = null is not valid, you'd
need to do column is null.

Anyway, I don't think a named query is the proper way to go about a
custom search.

I'd either use the expression API or a dynamically build query.

/tim

On Fri, May 9, 2008 at 9:08 AM, Leon Derks <leon.derks@xxxxxxxxxx> wrote:
Hi

Yes I tried executing the query with the null params, but then no results
are returned.

For example when productCategory is null, I want to get all items.
So skipping the (where productCategory = :productCategory) part in my named
query.

There are three search params, with can all be null. So we have 8 different
search situations.
I can make 8 different queries, but this is to complex I think.

Therefore I hoped there was I way to skip the null parts in a named query.

How is this normally done?

Leon

Tim Hollosy wrote:
Did you try setting them to null?

On Fri, May 9, 2008 at 4:08 AM, Leon Derks <leon.derks@xxxxxxxxxx> wrote:

Hello

I have a named query with three parameters.

These parameters are search parameters and can be null.

When I don't set the parameter in my DAO I get the following error:
"Query
argument productName not found in the list of parameters provided during
query execution"

Is there a way to ignore the null parameters in my named query and only
use
the parameters that are not null?

Leon
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users




_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users







Back to the top