Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] What am I missing?

Should be,
    if(criteria != null)
    {
        query.setSelectionCriteria(eb.get("departmentId").equal(
criteria.getDepartmentId() ));
    }



testit wrote:
> 
> The following query always returns all the rows.  When criteria is not
> null then departmentId has an int value.  It is like I have never set the
> expression but I see it under debug.  What is the deal?  
> 
> public List<Employee> getEmployees( Employee criteria, int page,
>         int limit ) throws Exception
> {
>     ReadAllQuery query = new ReadAllQuery(Employee.class);
>     ExpressionBuilder eb = query.getExpressionBuilder();
>     query.addAscendingOrdering ("lastName");
>     query.addAscendingOrdering ("firstName");
>     if(criteria != null)
>     {
>         eb.get("departmentId").equal( criteria.getDepartmentId() );
>     }
>     query.setSelectionCriteria(eb);
>     query.refreshIdentityMapResult();
>     List employees = (List) session.executeQuery(query);
>     return employees;
> }
> 


-----
---
http://wiki.eclipse.org/User:James.sutherland.oracle.com James Sutherland 
http://www.eclipse.org/eclipselink/
 EclipseLink ,  http://www.oracle.com/technology/products/ias/toplink/
TopLink 
Wiki:  http://wiki.eclipse.org/EclipseLink EclipseLink , 
http://wiki.oracle.com/page/TopLink TopLink 
Forums:  http://forums.oracle.com/forums/forum.jspa?forumID=48 TopLink , 
http://www.nabble.com/EclipseLink-f26430.html EclipseLink 
Book:  http://en.wikibooks.org/wiki/Java_Persistence Java Persistence 
-- 
View this message in context: http://www.nabble.com/What-am-I-missing--tp20544738p20560252.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.



Back to the top