0 Replies Latest reply on Jul 24, 2008 5:27 AM by koatto

    @NamedNativeQuery and collection loading


      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
       if (query.getNamedParameters().length > 0)
       query.setParameter(query.getNamedParameters()[0], key, persister
       query.setParameter(0, key, persister.getKeyType());

      which confirms that just the first parameter is applied, referring its type as the key one.

      Is there a way to pass more than one parameter?