Package org.hibernate.persister.entity

Examples of org.hibernate.persister.entity.Queryable


        throw new QueryException( "alias not found: " + name );
      }
      return getCollectionPersister( role ); //.getElementPropertyMapping();
    }
    else {
      Queryable persister = getEntityPersister( type );
      if ( persister == null ) throw new QueryException( "persistent class not found: " + type );
      return persister;
    }
  }
View Full Code Here


    decoratedPropertyMappings.put( name, mapping );
  }

  private Queryable getEntityPersisterForName(String name) throws QueryException {
    String type = getType( name );
    Queryable persister = getEntityPersister( type );
    if ( persister == null ) throw new QueryException( "persistent class not found: " + type );
    return persister;
  }
View Full Code Here

      CollectionPersister p = getCollectionPersister( ( String ) iter.next() );
      addQuerySpaces( p.getCollectionSpaces() );
    }
    iter = typeMap.keySet().iterator();
    while ( iter.hasNext() ) {
      Queryable p = getEntityPersisterForName( ( String ) iter.next() );
      addQuerySpaces( p.getQuerySpaces() );
    }

    sqlString = sql.toQueryString();

    if ( holderClass != null ) holderConstructor = ReflectHelper.getConstructor( holderClass, returnTypes );
View Full Code Here

  protected void postProcessDML(RestrictableStatement statement) throws SemanticException {
    statement.getFromClause().resolve();

    FromElement fromElement = (FromElement) statement.getFromClause().getFromElements().get( 0 );
    Queryable persister = fromElement.getQueryable();
    // Make #@%$^#^&# sure no alias is applied to the table name
    fromElement.setText( persister.getTableName() );

//    // append any filter fragments; the EMPTY_MAP is used under the assumption that
//    // currently enabled filters should not affect this process
//    if ( persister.getDiscriminatorType() != null ) {
//      new SyntheticAndFactory( getASTFactory() ).addDiscriminatorWhereFragment(
//              statement,
//              persister,
//              java.util.Collections.EMPTY_MAP,
//              fromElement.getTableAlias()
//      );
//    }
    if ( persister.getDiscriminatorType() != null || !queryTranslatorImpl.getEnabledFilters().isEmpty() ) {
      new SyntheticAndFactory( this ).addDiscriminatorWhereFragment(
          statement,
          persister,
          queryTranslatorImpl.getEnabledFilters(),
          fromElement.getTableAlias()
View Full Code Here

  protected void postProcessInsert(AST insert) throws SemanticException, QueryException {
    InsertStatement insertStatement = (InsertStatement) insert;
    insertStatement.validate();

    SelectClause selectClause = insertStatement.getSelectClause();
    Queryable persister = insertStatement.getIntoClause().getQueryable();

    if ( !insertStatement.getIntoClause().isExplicitIdInsertion() ) {
      // the insert did not explicitly reference the id.  See if
      //    1) that is allowed
      //    2) whether we need to alter the SQL tree to account for id
      final IdentifierGenerator generator = persister.getIdentifierGenerator();
      if ( !BulkInsertionCapableIdentifierGenerator.class.isInstance( generator ) ) {
        throw new QueryException(
            "Invalid identifier generator encountered for implicit id handling as part of bulk insertions"
        );
      }
      final BulkInsertionCapableIdentifierGenerator capableGenerator =
          BulkInsertionCapableIdentifierGenerator.class.cast( generator );
      if ( !capableGenerator.supportsBulkInsertionIdentifierGeneration() ) {
        throw new QueryException(
            "Identifier generator reported it does not support implicit id handling as part of bulk insertions"
        );
      }

      final String fragment = capableGenerator.determineBulkInsertionIdentifierGenerationSelectFragment(
          sessionFactoryHelper.getFactory().getDialect()
      );
      if ( fragment != null ) {
        // we got a fragment from the generator, so alter the sql tree...
        //
        // first, wrap the fragment as a node
        AST fragmentNode = getASTFactory().create( HqlSqlTokenTypes.SQL_TOKEN, fragment );
        // next, rearrange the SQL tree to add the fragment node as the first select expression
        AST originalFirstSelectExprNode = selectClause.getFirstChild();
        selectClause.setFirstChild( fragmentNode );
        fragmentNode.setNextSibling( originalFirstSelectExprNode );
        // finally, prepend the id column name(s) to the insert-spec
        insertStatement.getIntoClause().prependIdColumnSpec();
      }
    }

    if ( sessionFactoryHelper.getFactory().getDialect().supportsParametersInInsertSelect() ) {
      AST child = selectClause.getFirstChild();
      int i = 0;
      while ( child != null ) {
        if ( child instanceof ParameterNode ) {
          // infer the parameter type from the type listed in the INSERT INTO clause
          ( (ParameterNode) child ).setExpectedType(
              insertStatement.getIntoClause()
                  .getInsertionTypes()[selectClause.getParameterPositions().get( i )]
          );
          i++;
        }
        child = child.getNextSibling();
      }
    }

    final boolean includeVersionProperty = persister.isVersioned() &&
        !insertStatement.getIntoClause().isExplicitVersionInsertion() &&
        persister.isVersionPropertyInsertable();
    if ( includeVersionProperty ) {
      // We need to seed the version value as part of this bulk insert
      VersionType versionType = persister.getVersionType();
      AST versionValueNode = null;

      if ( sessionFactoryHelper.getFactory().getDialect().supportsParametersInInsertSelect() ) {
        int[] sqlTypes = versionType.sqlTypes( sessionFactoryHelper.getFactory() );
        if ( sqlTypes == null || sqlTypes.length == 0 ) {
View Full Code Here

  }

  @Override
  protected void evaluateAssignment(AST eq) throws SemanticException {
    prepareLogicOperator( eq );
    Queryable persister = getCurrentFromClause().getFromElement().getQueryable();
    evaluateAssignment( eq, persister, -1 );
  }
View Full Code Here

    return assignmentSpecifications;
  }

  @Override
  protected AST createIntoClause(String path, AST propertySpec) throws SemanticException {
    Queryable persister = (Queryable) getSessionFactoryHelper().requireClassPersister( path );

    IntoClause intoClause = (IntoClause) getASTFactory().create( INTO, persister.getEntityName() );
    intoClause.setFirstChild( propertySpec );
    intoClause.initialize( persister );

    addQuerySpaces( persister.getQuerySpaces() );

    return intoClause;
  }
View Full Code Here

  protected void prepareVersioned(AST updateNode, AST versioned) throws SemanticException {
    UpdateStatement updateStatement = (UpdateStatement) updateNode;
    FromClause fromClause = updateStatement.getFromClause();
    if ( versioned != null ) {
      // Make sure that the persister is versioned
      Queryable persister = fromClause.getFromElement().getQueryable();
      if ( !persister.isVersioned() ) {
        throw new SemanticException( "increment option specified for update of non-versioned entity" );
      }

      VersionType versionType = persister.getVersionType();
      if ( versionType instanceof UserVersionType ) {
        throw new SemanticException( "user-defined version types not supported for increment option" );
      }

      AST eq = getASTFactory().create( HqlSqlTokenTypes.EQ, "=" );
View Full Code Here

    }
    select.appendFromClauseFragment( fromTableFragment + outerJoinLoadable.fromJoinFragment( rootAlias, true, true ) );
  }

  protected void applyRootReturnFilterRestrictions(SelectStatementBuilder selectStatementBuilder) {
    final Queryable rootQueryable = (Queryable) getRootEntityReturn().getEntityPersister();
    selectStatementBuilder.appendRestrictions(
        rootQueryable.filterFragment(
            entityReferenceAliases.getTableAlias(),
            Collections.emptyMap()
        )
    );
  }
View Full Code Here

  @Override
  public TypedValue getTypedValue(Criteria subcriteria, String propertyName, Object value) throws HibernateException {
    // Detect discriminator values...
    if ( value instanceof Class ) {
      final Class entityClass = (Class) value;
      final Queryable q = SessionFactoryHelper.findQueryableUsingImports( sessionFactory, entityClass.getName() );
      if ( q != null ) {
        final Type type = q.getDiscriminatorType();
        String stringValue = q.getDiscriminatorSQLValue();
        if ( stringValue != null
            && stringValue.length() > 2
            && stringValue.startsWith( "'" )
            && stringValue.endsWith( "'" ) ) {
          // remove the single quotes
View Full Code Here

TOP

Related Classes of org.hibernate.persister.entity.Queryable

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.