cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michael Gentry" <blackn...@gmail.com>
Subject Re: Get the number of FKs
Date Thu, 06 Mar 2008 19:08:25 GMT
It seems you mainly want a list of employees who are not in a
department, so doing a fetch on Employee where "department = null"
might work (I'm not positive I've ever tried this, but it seems
logical to me).

/dev/mrg

On Thu, Mar 6, 2008 at 1:58 PM, Scott Anderson <sanderson@airvana.com> wrote:
> I've got a one-to-many relationship (employees belong to a department),
>  and I'd like to search for departments that have no employees.
>  Currently, I have something like:
>
>  foreach(dept : departments) {
>     if(dept.getEmployees().size() == 0)
>         context.deleteObject(dept);
>  }
>
>  When I do this, it has the effect of telling Cayenne to fetch data rows
>  for every employee in the database; this will not scale well. Is there
>  any way I can get the size of the array without doing a custom SELECT
>  query?
>

Mime
View raw message