You can do this using HQL:
var query = session.CreateQuery("from Job j where :plan in elements(j.PlansUsed)")
.SetParameter("plan", "BBB");
var jobsViaHql = query.List<Job>();
foreach(var job in jobsViaHql) {
Console.WriteLine(job.Id);
}
I couldn't figure out a way to do it with the Criteria API other than using direct SQL subquery as you suggest. Like in the HQL, you want to check whether some plan ("BBB") is in the PlansUsed bag. There are Criteria for checking whether a property (single-valued) is in a collection of values that you supply, but not the other way around. Maybe someone else knows a way around this.
James
--
James Kovacs, B.Sc., M.Sc., MCSD, MCT
Microsoft MVP - C# Architecture
http://www.jameskovacs.comjko...@post.harvard.edu
403-397-3177 (mobile)