Package org.hibernate.type

Examples of org.hibernate.type.Type


   * @return The type.
   * @0param propertyPath The full property path.
   */
  public Type getPropertyType(String propertyName, String propertyPath) {
    checkInitialized();
    Type type = null;
    // If this is an entity and the property is the identifier property, then use getIdentifierType().
    //      Note that the propertyName.equals( propertyPath ) checks whether we have a component
    //      key reference, where the component class property name is the same as the
    //      entity id property name; if the two are not equal, this is the case and
    //      we'd need to "fall through" to using the property mapping.
View Full Code Here


        //sqlResultTypeList.addAll( constructorArgumentTypeList );
        queryReturnTypeList.addAll( constructorArgumentTypeList );
        scalarSelect = true;
      }
      else {
        Type type = expr.getDataType();
        if ( type == null ) {
          throw new IllegalStateException( "No data type for node: " + expr.getClass().getName() + " "
              + new ASTPrinter( SqlTokenTypes.class ).showAsString( ( AST ) expr, "" ) );
        }
        //sqlResultTypeList.add( type );

        // If the data type is not an association type, it could not have been in the FROM clause.
        if ( expr.isScalar() ) {
          scalarSelect = true;
        }

        if ( isReturnableEntity( expr ) ) {
          fromElementsForLoad.add( expr.getFromElement() );
        }

        // Always add the type to the return type list.
        queryReturnTypeList.add( type );
      }
    }

    //init the aliases, after initing the constructornode
    initAliases(selectExpressions);

    if ( !getWalker().isShallowQuery() ) {
      // add the fetched entities
      List fromElements = fromClause.getProjectionList();
 
      ASTAppender appender = new ASTAppender( getASTFactory(), this )// Get ready to start adding nodes.
      int size = fromElements.size();
 
      Iterator iterator = fromElements.iterator();
      for ( int k = 0; iterator.hasNext(); k++ ) {
        FromElement fromElement = ( FromElement ) iterator.next();
 
        if ( fromElement.isFetch() ) {
          FromElement origin = null;
          if ( fromElement.getRealOrigin() == null ) {
            // work around that crazy issue where the tree contains
            // "empty" FromElements (no text); afaict, this is caused
            // by FromElementFactory.createCollectionJoin()
            if ( fromElement.getOrigin() == null ) {
              throw new QueryException( "Unable to determine origin of join fetch [" + fromElement.getDisplayText() + "]" );
            }
            else {
              origin = fromElement.getOrigin();
            }
          }
          else {
            origin = fromElement.getRealOrigin();
          }
          if ( !fromElementsForLoad.contains( origin ) ) {
            throw new QueryException(
                "query specified join fetching, but the owner " +
                "of the fetched association was not present in the select list " +
                "[" + fromElement.getDisplayText() + "]"
            );
          }
          Type type = fromElement.getSelectType();
          addCollectionFromElement( fromElement );
          if ( type != null ) {
            boolean collectionOfElements = fromElement.isCollectionOfValuesOrComponents();
            if ( !collectionOfElements ) {
              // Add the type to the list of returned sqlResultTypes.
View Full Code Here

    ArrayList queryReturnTypeList = new ArrayList( size );

    Iterator iterator = fromElements.iterator();
    for ( int k = 0; iterator.hasNext(); k++ ) {
      FromElement fromElement = ( FromElement ) iterator.next();
      Type type = fromElement.getSelectType();

      addCollectionFromElement( fromElement );

      if ( type != null ) {
        boolean collectionOfElements = fromElement.isCollectionOfValuesOrComponents();
View Full Code Here

    while ( params.hasNext() ) {
      final Element param = (Element) params.next();
      final String paramName = param.attributeValue( "name" );
      final String paramType = param.attributeValue( "type" );
      log.debug( "adding filter parameter : " + paramName + " -> " + paramType );
      final Type heuristicType = TypeFactory.heuristicType( paramType );
      log.debug( "parameter heuristic type : " + heuristicType );
      paramMappings.put( paramName, heuristicType );
    }
    log.debug( "Parsed filter-def [" + name + "]" );
    FilterDefinition def = new FilterDefinition( name, defaultCondition, paramMappings );
View Full Code Here

  public Type getType() throws MappingException {
    if (typeName==null) {
      throw new MappingException("No type name");
    }
    Type result = TypeFactory.heuristicType(typeName, typeParameters);
    if (result==null) {
      String msg = "Could not determine type for: " + typeName;
      if(table != null){
        msg += ", at table: " + table.getName();
      }
View Full Code Here

   */
  private void addFromAssociation(final String elementName, final String collectionRole)
      throws QueryException {
    //q.addCollection(collectionName, collectionRole);
    QueryableCollection persister = getCollectionPersister( collectionRole );
    Type collectionElementType = persister.getElementType();
    if ( !collectionElementType.isEntityType() ) {
      throw new QueryException( "collection of values in filter: " + elementName );
    }

    String[] keyColumnNames = persister.getKeyColumnNames();
    //if (keyColumnNames.length!=1) throw new QueryException("composite-key collection in filter: " + collectionRole);
View Full Code Here

      if ( isFilter() ) {
        // Handle collection-fiter compilation.
        // IMPORTANT NOTE: This is modifying the INPUT (HQL) tree, not the output tree!
        QueryableCollection persister = sessionFactoryHelper.getCollectionPersister( collectionFilterRole );
        Type collectionElementType = persister.getElementType();
        if ( !collectionElementType.isEntityType() ) {
          throw new QueryException( "collection of values in filter: this" );
        }

        String collectionElementEntityName = persister.getElementPersister().getEntityName();
        ASTFactory inputAstFactory = hqlParser.getASTFactory();
        AST fromElement = ASTUtil.create( inputAstFactory, HqlTokenTypes.FILTER_ENTITY, collectionElementEntityName );
        ASTUtil.createSibling( inputAstFactory, HqlTokenTypes.ALIAS, "this", fromElement );
        fromClauseInput.addChild( fromElement );
        // Show the modified AST.
        if ( log.isDebugEnabled() ) {
          log.debug( "prepareFromClauseInputTree() : Filter - Added 'this' as a from element..." );
        }
        queryTranslatorImpl.showHqlAst( hqlParser.getAST() );

        // Create a parameter specification for the collection filter...
        Type collectionFilterKeyType = sessionFactoryHelper.requireQueryableCollection( collectionFilterRole ).getKeyType();
        ParameterNode collectionFilterKeyParameter = ( ParameterNode ) astFactory.create( PARAM, "?" );
        CollectionFilterKeyParameterSpecification collectionFilterKeyParameterSpec = new CollectionFilterKeyParameterSpecification(
            collectionFilterRole, collectionFilterKeyType, positionalParameterCount++
        );
        collectionFilterKeyParameter.setHqlParameterSpecification( collectionFilterKeyParameterSpec );
View Full Code Here

  private void dialectFunction(AST exprList) {
    function = getSessionFactoryHelper().findSQLFunction( methodName );
    if ( function != null ) {
      AST firstChild = exprList != null ? exprList.getFirstChild() : null;
      Type functionReturnType = getSessionFactoryHelper()
          .findFunctionReturnType( methodName, firstChild );
      setDataType( functionReturnType );
    }
    //TODO:
    /*else {
View Full Code Here

    if ( path == null ) {
      throw new SemanticException( "Collection function " + name.getText() + " has no path!" );
    }

    SqlNode expr = ( SqlNode ) path;
    Type type = expr.getDataType();
    if ( log.isDebugEnabled() ) {
      log.debug( "collectionProperty() :  name=" + name + " type=" + type );
    }

    resolveCollectionProperty( expr );
View Full Code Here

    return this;
  }

  public Query setParameter(String name, Object val) throws HibernateException {
    if (val == null) {
      Type type = parameterMetadata.getNamedParameterExpectedType( name );
      if ( type == null ) {
        type = Hibernate.SERIALIZABLE;
      }
      setParameter( name, val, type );
    }
View Full Code Here

TOP

Related Classes of org.hibernate.type.Type

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.