Hi Everyone,
I've got a problem writing a HQL query, I have an object which contains a set of "Berths" and I want all the objects back whos set of "Berths" is contained within a set of "Berths" that I pass to the query.
In Java it would look like this
Code:
Set<Berth> setParameter = getSomeBerthObjects();
for(NetworkIncident ni : allNetworkIncidents){
if(setParameter.containsAll(ni.getBerthSet())){
return NetworkIncident;
}
}
The query i've written so far is
Code:
select
ni from NetworkIncidentImpl ni join ni.berths b
where
b in (:berths)
But the problem is I get an error
Code:
org.hibernate.PropertyAccessException: could not get a field value by reflection getter of BerthImpl.id
I've tried changing it so I pass in a set of Long of the berth objects Id and compare with b.id and this then has a cast exception where it says cannot cast from HashSet to Long. It seems its expecting only a single long and not a set. I've also tried an Array with no avail.
Any help would be much appreciated thanks!
edit:
Silly me I found the method setParameterList() on the query and this has allowed me to run the above query. The only problem now is that it will return any NetworkIncident that has atleast 1 berth in the (:berths) set. I need it so that only if all the berths on a network incident are contained in the (:berths) set are returned preferably. :D