예제 #1
0
  @Override
  public Query getNamedSQLQuery(String queryName) {
    errorIfClosed();
    checkTransactionSynchStatus();

    NamedSQLQueryDefinition nsqlqd = findNamedNativeQuery(queryName);
    Query query =
        new NoSQLQueryImpl(
            nsqlqd, this, factory.getQueryPlanCache().getSQLParameterMetadata(nsqlqd.getQuery()));
    query.setComment("named native query " + queryName);
    return query;
  }
예제 #2
0
  /**
   * Constructs a SQLQueryImpl given a sql query defined in the mappings.
   *
   * @param queryDef The representation of the defined <sql-query/>.
   * @param session The session to which this SQLQueryImpl belongs.
   * @param parameterMetadata Metadata about parameters found in the query.
   */
  SQLQueryImpl(
      NamedSQLQueryDefinition queryDef,
      SessionImplementor session,
      ParameterMetadata parameterMetadata) {
    super(queryDef.getQueryString(), queryDef.getFlushMode(), session, parameterMetadata);
    if (queryDef.getResultSetRef() != null) {
      ResultSetMappingDefinition definition =
          session.getFactory().getResultSetMapping(queryDef.getResultSetRef());
      if (definition == null) {
        throw new MappingException(
            "Unable to find resultset-ref definition: " + queryDef.getResultSetRef());
      }
      this.queryReturns =
          new ArrayList<NativeSQLQueryReturn>(Arrays.asList(definition.getQueryReturns()));
    } else if (queryDef.getQueryReturns() != null && queryDef.getQueryReturns().length > 0) {
      this.queryReturns =
          new ArrayList<NativeSQLQueryReturn>(Arrays.asList(queryDef.getQueryReturns()));
    } else {
      this.queryReturns = new ArrayList<NativeSQLQueryReturn>();
    }

    this.querySpaces = queryDef.getQuerySpaces();
    this.callable = queryDef.isCallable();
  }
예제 #3
0
 @Override
 public SQLQuery createSQLQuery(NamedSQLQueryDefinition namedQueryDefinition) {
   return createNativeQuery(namedQueryDefinition.getQuery());
 }