I'm not very good in SQL and HQL...
I have two domains:
class Hotel {
String name
}
class Room {
Hotel hotel
float price
}
How many hotels have at least one room ?
I'm not very good in SQL and HQL...
I have two domains:
class Hotel {
String name
}
class Room {
Hotel hotel
float price
}
How many hotels have at least one room ?
You probably want to make this a bi-directional relationship.
class Hotel {
String name;
List<Room> rooms;
}
class Room {
Hotel hotel
float price
}
Then HQL:
from Hotel h where size(h.rooms) >= 1
Will return Hotels where the rooms collection has at least one value.
More details here.