public virtual IQuery GetNamedQuery(string queryName)
 {
     using (new SessionIdLoggingContext(SessionId))
     {
         CheckAndUpdateSessionStatus();
         NamedQueryDefinition nqd = factory.GetNamedQuery(queryName);
         IQuery query;
         if (nqd != null)
         {
             string queryString = nqd.QueryString;
             query = new QueryImpl(queryString, nqd.FlushMode, this,
                                   GetHQLQueryPlan(queryString, false).ParameterMetadata);
             query.SetComment("named HQL query " + queryName);
         }
         else
         {
             NamedSQLQueryDefinition nsqlqd = factory.GetNamedSQLQuery(queryName);
             if (nsqlqd == null)
             {
                 throw new MappingException("Named query not known: " + queryName);
             }
             query = new SqlQueryImpl(nsqlqd, this,
                                      factory.QueryPlanCache.GetSQLParameterMetadata(nsqlqd.QueryString));
             query.SetComment("named native SQL query " + queryName);
             nqd = nsqlqd;
         }
         InitQuery(query, nqd);
         return(query);
     }
 }
 public virtual ISQLQuery CreateSQLQuery(string sql)
 {
     using (new SessionIdLoggingContext(SessionId))
     {
         CheckAndUpdateSessionStatus();
         SqlQueryImpl query = new SqlQueryImpl(sql, this, factory.QueryPlanCache.GetSQLParameterMetadata(sql));
         query.SetComment("dynamic native SQL query");
         return(query);
     }
 }
 public virtual IQuery GetNamedSQLQuery(string name)
 {
     using (new SessionIdLoggingContext(SessionId))
     {
         CheckAndUpdateSessionStatus();
         NamedSQLQueryDefinition nsqlqd = factory.GetNamedSQLQuery(name);
         if (nsqlqd == null)
         {
             throw new MappingException("Named SQL query not known: " + name);
         }
         IQuery query = new SqlQueryImpl(nsqlqd, this,
                                         factory.QueryPlanCache.GetSQLParameterMetadata(nsqlqd.QueryString));
         query.SetComment("named native SQL query " + name);
         InitQuery(query, nsqlqd);
         return(query);
     }
 }