Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Expression API - Subquery referencing parent query possible?

All EclipseLink queries use the Expression API as the basis - any query that can be written in JPA can be written using expressions.

rough pseudo-code:

RAQ query = new ReadAllQuery(Department.class);
EB eb = query.getExpressionBuilder();

RQ rq = new ReportQuery(Employee.class);
rq.addItem(1);
EB innerEb = rq.getExpressionBuilder();
Expression innerExp = innerEb.get("departmentId").equal(eb.get("departementId"));
rq.setSelectionCritiera(innerExp);

Expression outerExp = eb.exists(rq);
query.setSelectionCriteria(outerExp);

-Tom

Tim Hollosy wrote:
What we're trying to do, is make a utility to do this generically
within the expression API. We've got a spring service that allows
developers to create search forms on entities without having to know
how to work the expression API.

Currently all our code uses expressions to build up the query so it's
more generic, I'd like to continue to do it this way. Would it be
possible to mix and match the two if the expression API can't do it?

Tim



On Tue, Jan 11, 2011 at 2:52 PM, Tom Ware <tom.ware@xxxxxxxxxx> wrote:
JPQL like what you have written below should work.  Are you having an issue?

Tim Hollosy wrote:
I'm not sure what this is called, but is it possible to create sql
like this with the expression API?

select * from department d
where
exists (select 1 from employee e where e.department_id = d.department_id)

This is important when to do when you're paging parent data but want
to search inside child data.

Thanks!
Tim
_______________________________________________
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

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


Back to the top