I'm using a parametrized named native query to initialize a collection property.
Everything seems to work fine except for the fact that hibernate passes just one parameter to the query which is the bean's id.
Looking at the hibernate's NamedQueryCollectionInitializer sources i found that :
public void initialize(Serializable key, SessionImplementor session) throws HibernateException { if (log.isDebugEnabled()) log.debug("initializing collection: " + persister.getRole() + " using named query: " + queryName); AbstractQueryImpl query = (AbstractQueryImpl) session .getNamedSQLQuery(queryName); if (query.getNamedParameters().length > 0) query.setParameter(query.getNamedParameters()[0], key, persister .getKeyType()); else query.setParameter(0, key, persister.getKeyType()); query.setCollectionKey(key).setFlushMode(FlushMode.MANUAL).list(); }