EJB-QL Query List inside Object

966 Views Asked by At

I'm attempting to write what should be a simple (I hope) EJB-QL query.

Here are my objects:

public class Room {
     private String name;
     private List<RoomConfiguration> configs;
}

public class RoomConfiguration {
     private Integer capacity;
     private String name;
}

How can I search for rooms with a minimum capacity? A room can have multiple configurations, and each of those configurations has a different capacity.

1

There are 1 best solutions below

0
On BEST ANSWER

Something like this:

select room, config 
from Room room 
left outer join room.configs config
where config.capacity = (select min(rc.capacity) from RoomConfiguration rc)