Just for the records, here is my solution:
Code:
List ids = ...
Query query = pSession.createQuery("select from BOCustomer as customer " +
"where customer.id in (:ids)");
query.setParameterList("ids", ids);
List results= query.list();
// sync the order of the result list with the order of the keys list
int n = results.size();
List back= new ArrayList(n);
Map map = new HashMap (n); // key= id, value= customer
for (int i = 0; i < n; i++)
{
BOCustomer customer= (BOCustomer) results.get(i);
Long id = new Long(customer.getId());
map.put(id, customer);
}
for (int i = 0, n = ids.size(); i < n; i++)
{
Long id = (Long)ids.get(i);
BOCustomer customer= (BOCustomer) map.get(id);
back.add(customer);
}
Bye,
J