Consider the following setup.
Space.java
class Space {
Id id;
ParkingCampus campus;
}
class ParkingCampus {
Id id;
String country;
}
This is not the exact structure of my project but it is close enough for what I am trying to understand.
How would I be able to run a query on my 'Space' object which only returns instances where the child class 'ParkingCampus' has the String 'country' set to a specific value, eg: "UK".
I was thinking something like:
sessionFactory.getCurrentSession()
.createCriteria(String.class)
.add(Restrictions.eq("country", "UK"))
.list();
But i'm not sure if that would compile correctly. So does Hibernate by default do a 'deep' search in an attempt to map results to my restriction criteria or do I need to do something else to specify the query to work in this way?
Any help would be greatly appreciated!