Package org.hibernate.engine.query

Examples of org.hibernate.engine.query.ParameterMetadata


   * If entities is empty, include all indexed entities
   *
   * @param entities must be immutable for the lifetime of the query object
   */
  public FullTextQuery createFullTextQuery(org.apache.lucene.search.Query luceneQuery, Class... entities) {
    return new FullTextQueryImpl( luceneQuery, entities, sessionImplementor, new ParameterMetadata( null, null ) );
  }
View Full Code Here


   * If entities is empty, include all indexed entities
   *
   * @param entities must be immutable for the lifetime of the query object
   */
  public FullTextQuery createFullTextQuery(org.apache.lucene.search.Query luceneQuery, Class... entities) {
    return new FullTextQueryImpl( luceneQuery, entities, sessionImplementor, new ParameterMetadata( null, null ) );
  }
View Full Code Here

   * If entities is empty, include all indexed entities
   *
   * @param entities must be immutable for the lifetime of the query object
   */
  public FullTextQuery createFullTextQuery(org.apache.lucene.search.Query luceneQuery, Class... entities) {
    return new FullTextQueryImpl( luceneQuery, entities, sessionImplementor, new ParameterMetadata( null, null ) );
  }
View Full Code Here

   * If entities is empty, include all indexed entities
   *
   * @param entities must be immutable for the lifetime of the query object
   */
  public FullTextQuery createFullTextQuery(org.apache.lucene.search.Query luceneQuery, Class... entities) {
    return new FullTextQueryImpl( luceneQuery, entities, sessionImplementor, new ParameterMetadata( null, null ) );
  }
View Full Code Here

   * If entities is empty, include all indexed entities
   *
   * @param entities must be immutable for the lifetime of the query object
   */
  public FullTextQuery createFullTextQuery(org.apache.lucene.search.Query luceneQuery, Class... entities) {
    return new FullTextQueryImpl( luceneQuery, entities, sessionImplementor, new ParameterMetadata(null, null) );
  }
View Full Code Here

  }

  public Query createQuery(String queryString) {
    errorIfClosed();
    HQLQueryPlan plan = getHQLQueryPlan( queryString, false );
    ParameterMetadata paraMetadata = plan.getParameterMetadata();
    QueryImpl query = new QueryImpl(
        queryString,
            this,
            paraMetadata
    );
View Full Code Here

   * If entities is empty, include all indexed entities
   *
   * @param entities must be immutable for the lifetime of the query object
   */
  public FullTextQuery createFullTextQuery(org.apache.lucene.search.Query luceneQuery, Class... entities) {
    return new FullTextQueryImpl( luceneQuery, entities, sessionImplementor, new ParameterMetadata( null, null ) );
  }
View Full Code Here

   
    // params
    if(params!=null){
      QueryPlanCache cache=data.getQueryPlanCache();
      HQLQueryPlan plan = cache.getHQLQueryPlan(hql, false, java.util.Collections.EMPTY_MAP);
      ParameterMetadata meta = plan.getParameterMetadata();
      Type type;
      Object obj;
     

      // struct
      if(CommonUtil.isStruct(params)) {
        Struct sct=CommonUtil.toStruct(params);
        Key[] keys   = CommonUtil.keys(sct);
        String name;
        // fix case-senstive
        Struct names=CommonUtil.createStruct();
        if(meta!=null){
          Iterator<String> it = meta.getNamedParameterNames().iterator();
          while(it.hasNext()){
            name=it.next();
            names.setEL(name, name);
          }
        }
       
        RefBoolean isArray=CommonUtil.createRefBoolean();
        for(int i=0;i<keys.length;i++){
          obj=sct.get(keys[i],null);
          if(meta!=null){
            name=(String) names.get(keys[i],null);
            if(name==null) continue; // param not needed will be ignored
            type = meta.getNamedParameterExpectedType(name);
            obj=HibernateCaster.toSQL(type, obj,isArray);
            if(isArray.toBooleanValue())
              query.setParameterList(name, (Object[])obj,type);
            else
              query.setParameter(name, obj,type);
           
           
          }
          else
            query.setParameter(keys[i].getString(), obj);
        }
      }
     
      // array
      else if(CommonUtil.isArray(params)){
        Array arr=CommonUtil.toArray(params);
        Iterator it = arr.valueIterator();
        int index=0;
        SQLItem item;
        RefBoolean isArray=null;
        while(it.hasNext()){
          obj=it.next();
          if(obj instanceof SQLItem) {
            item=(SQLItem) obj;
            obj=item.getValue();
            //HibernateCaster.toHibernateType(item.getType(), null); MUST
            //query.setParameter(index, item.getValue(),type);
          }
          if(meta!=null){
            type = meta.getOrdinalParameterExpectedType(index+1);
            obj=HibernateCaster.toSQL(type, obj,isArray);
            // TOOD can the following be done somehow
            //if(isArray.toBooleanValue())
            //  query.setParameterList(index, (Object[])obj,type);
            //else
              query.setParameter(index, obj,type);
          }
          else
            query.setParameter(index, obj);
          index++;
        }
        if(meta.getOrdinalParameterCount()>index)
          throw ExceptionUtil.createException(this,null,"parameter array is to small ["+arr.size()+"], need ["+meta.getOrdinalParameterCount()+"] elements",null);
      }
    }
   
   
   
View Full Code Here

   * If entities is empty, include all indexed entities
   *
   * @param entities must be immutable for the lifetime of the query object
   */
  public FullTextQuery createFullTextQuery(org.apache.lucene.search.Query luceneQuery, Class... entities) {
    return new FullTextQueryImpl( luceneQuery, entities, sessionImplementor, new ParameterMetadata( null, null ) );
  }
View Full Code Here

   * If entities is empty, include all indexed entities
   *
   * @param entities must be immutable for the lifetime of the query object
   */
  public FullTextQuery createFullTextQuery(org.apache.lucene.search.Query luceneQuery, Class... entities) {
    return new FullTextQueryImpl( luceneQuery, entities, sessionImplementor, new ParameterMetadata( null, null ) );
  }
View Full Code Here

TOP

Related Classes of org.hibernate.engine.query.ParameterMetadata

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.