public List query(Object primaryKey) { // for a unidirectional one-to-many we use the embedded keys if (!association.isBidirectional()) { final Object indexed = nativeEntry.get(association.getName()); if (indexed instanceof Collection) { if (indexed instanceof List) return (List) indexed; return new ArrayList((Collection) indexed); } return Collections.emptyList(); } // for a bidirectional one-to-many we use the foreign key to query the inverse side of the // association Association inverseSide = association.getInverseSide(); Query query = session.createQuery(association.getAssociatedEntity().getJavaClass()); query.eq(inverseSide.getName(), primaryKey); query.projections().id(); return query.list(); }