예제 #1
0
        public QueryTranslator[] GetQuery(string queryString, bool shallow)
        {
            QueryCacheKey cacheKey = new QueryCacheKey(queryString, shallow);

            // have to be careful to ensure that if the JVM does out-of-order execution
            // then another thread can't get an uncompiled QueryTranslator from the cache
            // we also have to be very careful to ensure that other threads can perform
            // compiled queries while another query is being compiled

            QueryTranslator[] queries = ( QueryTranslator[] )Get(cacheKey);

            if (queries == null)
            {
                // a query that names an interface or unmapped class in the from clause
                // is actually executed as multiple queries
                string[] concreteQueryStrings = QueryTranslator.ConcreteQueries(queryString, this);
                queries = CreateQueryTranslators(concreteQueryStrings, cacheKey);
            }

            foreach (QueryTranslator q in queries)
            {
                q.Compile(this, settings.QuerySubstitutions, shallow);
            }
            // see comment above. note that QueryTranslator.compile() is synchronized

            return(queries);
        }
예제 #2
0
 public IType[] GetReturnTypes(String queryString)
 {
     string[] queries = QueryTranslator.ConcreteQueries(queryString, this);
     if (queries.Length == 0)
     {
         throw new HibernateException("Query does not refer to any persistent classes: " + queryString);
     }
     return(GetQuery(queries[0], true)[0].ReturnTypes);
 }