Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » I must be missing something!
I must be missing something! [message #383029] Mon, 17 November 2008 18:45 Go to next message
testit is currently offline testitFriend
Messages: 1
Registered: July 2009
Junior Member
This always returns all of the rows in the table. There are only a couple
of rows where departmentId is equal to 1.

What did I miss?

public List<Employee> getEmployees( Employee criteria, int page,
int limit ) throws Exception
{
ReadAllQuery query = new ReadAllQuery(Employee.class);
ExpressionBuilder eb = query.getExpressionBuilder();
eb.get("departmentId").equal( 1 );
query.setSelectionCriteria(eb);
query.refreshIdentityMapResult();
List employees = (List) session.executeQuery(query);
return employees;
}
Re: I must be missing something! [message #383033 is a reply to message #383029] Tue, 18 November 2008 13:25 Go to previous message
Doug Clarke is currently offline Doug ClarkeFriend
Messages: 155
Registered: July 2009
Senior Member
The line:

eb.get("departmentId").equal( 1 );

creates an expression object that you need to set into the selection
criteria. The ExpressionBuilder is a factory for these expressions. If you
re-write your code as:



> public List<Employee> getEmployees( Employee criteria, int page,
> int limit ) throws Exception
> {
> ReadAllQuery query = new ReadAllQuery(Employee.class);
> ExpressionBuilder eb = query.getExpressionBuilder();
> Expression exp = eb.get("departmentId").equal( 1 );
> query.setSelectionCriteria(exp);
> query.refreshIdentityMapResult();
> List employees = (List) session.executeQuery(query);
> return employees;
> }

It should work for you.

Doug
Previous Topic:EJBQL translaltion problem
Next Topic:PostLoad on a new instance?
Goto Forum:
  


Current Time: Thu Apr 18 20:10:11 GMT 2024

Powered by FUDForum. Page generated in 0.01843 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top