Package org.hibernate.engine

Examples of org.hibernate.engine.SessionFactoryImplementor


        entry.postUpdate(instance, state, version);
      }
     
    }

    final SessionFactoryImplementor factory = getSession().getFactory();

    if ( isCachePutEnabled( persister, session ) ) {
     
      CacheEntry ce = new CacheEntry(
          state,
          persister,
          persister.hasUninitializedLazyProperties( instance, session.getEntityMode() ),
          version,
          session,
          instance
        );
     
      cacheEntry = persister.getCacheEntryStructure().structure(ce);
      final CacheKey ck = new CacheKey(
          id,
          persister.getIdentifierType(),
          persister.getRootEntityName(),
          session.getEntityMode(),
          session.getFactory()
        );
//      boolean put = persister.getCache().insert(ck, cacheEntry);
      boolean put = persister.getCacheAccessStrategy().insert( ck, cacheEntry, version );
     
      if ( put && factory.getStatistics().isStatisticsEnabled() ) {
        factory.getStatisticsImplementor().secondLevelCachePut( getPersister().getCacheAccessStrategy().getRegion().getName() );
      }
     
    }

    postInsert();

    if ( factory.getStatistics().isStatisticsEnabled() && !veto ) {
      factory.getStatisticsImplementor()
          .insertEntity( getPersister().getEntityName() );
    }

  }
View Full Code Here


    // resolve an expected type
    Type operandType = extractDataType( getOperand() );
    if ( operandType == null ) {
      return;
    }
    SessionFactoryImplementor sessionFactory = getSessionFactoryHelper().getFactory();
    int operandColumnSpan = operandType.getColumnSpan( sessionFactory );
    if ( operandColumnSpan > 1 ) {
      mutateRowValueConstructorSyntax( operandColumnSpan );
    }
  }
View Full Code Here

  protected final void mutateRowValueConstructorSyntaxesIfNecessary(Type lhsType, Type rhsType) {
    // TODO : this really needs to be delayed unitl after we definitively know all node types
    // where this is currently a problem is parameters for which where we cannot unequivocally
    // resolve an expected type
    SessionFactoryImplementor sessionFactory = getSessionFactoryHelper().getFactory();
    if ( lhsType != null && rhsType != null ) {
      int lhsColumnSpan = lhsType.getColumnSpan( sessionFactory );
      if ( lhsColumnSpan != rhsType.getColumnSpan( sessionFactory ) ) {
        throw new TypeMismatchException(
            "left and right hand sides of a binary logic operator were incompatibile [" +
            lhsType.getName() + " : "+ rhsType.getName() + "]"
        );
      }
      if ( lhsColumnSpan > 1 ) {
        // for dialects which are known to not support ANSI-SQL row-value-constructor syntax,
        // we should mutate the tree.
        if ( !sessionFactory.getDialect().supportsRowValueConstructorSyntax() ) {
          mutateRowValueConstructorSyntax( lhsColumnSpan );
        }
      }
    }
  }
View Full Code Here

    String[] cleanSql = cleanSqlCache.get(processEngine);

    if (cleanSql == null) {
      Configuration configuration = processEngine.get(Configuration.class);
     
      SessionFactoryImplementor sessionFactoryImplementor = (SessionFactoryImplementor) sessionFactory;
      Dialect dialect = sessionFactoryImplementor.getDialect();

      // loop over all foreign key constraints
      List<String> dropForeignKeysSql = new ArrayList<String>();
      List<String> createForeignKeysSql = new ArrayList<String>();
      Iterator<Table> iter = configuration.getTableMappings();
View Full Code Here

      beginTransaction();
    }
  }

  public boolean isTransactionActive() {
    SessionFactoryImplementor sessionFactory = (SessionFactoryImplementor) getSessionFactory();
    return JTAHelper.isTransactionInProgress(sessionFactory);
  }
View Full Code Here

        && source.getCacheMode().isGetEnabled()
        && event.getLockMode().lessThan(LockMode.READ);

    if ( useCache ) {

      final SessionFactoryImplementor factory = source.getFactory();

      final CacheKey ck = new CacheKey(
          event.getEntityId(),
          persister.getIdentifierType(),
          persister.getRootEntityName(),
          source.getEntityMode(),
          source.getFactory()
      );
      Object ce = persister.getCacheAccessStrategy().get( ck, source.getTimestamp() );
      if ( factory.getStatistics().isStatisticsEnabled() ) {
        if ( ce == null ) {
          factory.getStatisticsImplementor().secondLevelCacheMiss(
              persister.getCacheAccessStrategy().getRegion().getName()
          );
        }
        else {
          factory.getStatisticsImplementor().secondLevelCacheHit(
              persister.getCacheAccessStrategy().getRegion().getName()
          );
        }
      }
View Full Code Here

      final EntityPersister persister,
      final LoadEvent event) throws HibernateException {

    final Object optionalObject = event.getInstanceToLoad();
    final EventSource session = event.getSession();
    final SessionFactoryImplementor factory = session.getFactory();

    if ( log.isTraceEnabled() ) {
      log.trace(
          "assembling entity from second-level cache: " +
          MessageHelper.infoString( persister, id, factory )
        );
    }

    EntityPersister subclassPersister = factory.getEntityPersister( entry.getSubclass() );
    Object result = optionalObject == null ?
        session.instantiate( subclassPersister, id ) : optionalObject;

    // make it circular-reference safe
    EntityKey entityKey = new EntityKey( id, subclassPersister, session.getEntityMode() );
View Full Code Here

    SessionImplementor session = getSession();
    Object instance = getInstance();

    boolean veto = preUpdate();

    final SessionFactoryImplementor factory = getSession().getFactory();
    Object previousVersion = this.previousVersion;
    if ( persister.isVersionPropertyGenerated() ) {
      // we need to grab the version value from the entity, otherwise
      // we have issues with generated-version entities that may have
      // multiple actions queued during the same flush
      previousVersion = persister.getVersion( instance, session.getEntityMode() );
    }
   
    final CacheKey ck;
    if ( persister.hasCache() ) {
      ck = new CacheKey(
          id,
          persister.getIdentifierType(),
          persister.getRootEntityName(),
          session.getEntityMode(),
          session.getFactory()
      );
      lock = persister.getCacheAccessStrategy().lockItem( ck, previousVersion );
    }
    else {
      ck = null;
    }

    if ( !veto ) {
      persister.update(
          id,
          state,
          dirtyFields,
          hasDirtyCollection,
          previousState,
          previousVersion,
          instance,
          rowId,
          session
      );
    }

    EntityEntry entry = getSession().getPersistenceContext().getEntry( instance );
    if ( entry == null ) {
      throw new AssertionFailure( "possible nonthreadsafe access to session" );
    }
   
    if ( entry.getStatus()==Status.MANAGED || persister.isVersionPropertyGenerated() ) {
      // get the updated snapshot of the entity state by cloning current state;
      // it is safe to copy in place, since by this time no-one else (should have)
      // has a reference  to the array
      TypeHelper.deepCopy(
          state,
          persister.getPropertyTypes(),
          persister.getPropertyCheckability(),
          state,
          session
      );
      if ( persister.hasUpdateGeneratedProperties() ) {
        // this entity defines proeprty generation, so process those generated
        // values...
        persister.processUpdateGeneratedProperties( id, instance, state, session );
        if ( persister.isVersionPropertyGenerated() ) {
          nextVersion = Versioning.getVersion( state, persister );
        }
      }
      // have the entity entry doAfterTransactionCompletion post-update processing, passing it the
      // update state and the new version (if one).
      entry.postUpdate( instance, state, nextVersion );
    }

    if ( persister.hasCache() ) {
      if ( persister.isCacheInvalidationRequired() || entry.getStatus()!=Status.MANAGED ) {
        persister.getCacheAccessStrategy().remove( ck );
      }
      else {
        //TODO: inefficient if that cache is just going to ignore the updated state!
        CacheEntry ce = new CacheEntry(
            state,
            persister,
            persister.hasUninitializedLazyProperties( instance, session.getEntityMode() ),
            nextVersion,
            getSession(),
            instance
        );
        cacheEntry = persister.getCacheEntryStructure().structure( ce );
        boolean put = persister.getCacheAccessStrategy().update( ck, cacheEntry, nextVersion, previousVersion );
        if ( put && factory.getStatistics().isStatisticsEnabled() ) {
          factory.getStatisticsImplementor().secondLevelCachePut( getPersister().getCacheAccessStrategy().getRegion().getName() );
        }
      }
    }

    postUpdate();

    if ( factory.getStatistics().isStatisticsEnabled() && !veto ) {
      factory.getStatisticsImplementor()
          .updateEntity( getPersister().getEntityName() );
    }
  }
View Full Code Here

        entry.postUpdate(instance, state, version);
      }
     
    }

    final SessionFactoryImplementor factory = getSession().getFactory();

    if ( isCachePutEnabled( persister, session ) ) {
     
      CacheEntry ce = new CacheEntry(
          state,
          persister,
          persister.hasUninitializedLazyProperties( instance, session.getEntityMode() ),
          version,
          session,
          instance
        );
     
      cacheEntry = persister.getCacheEntryStructure().structure(ce);
      final CacheKey ck = new CacheKey(
          id,
          persister.getIdentifierType(),
          persister.getRootEntityName(),
          session.getEntityMode(),
          session.getFactory()
        );
      boolean put = persister.getCacheAccessStrategy().insert( ck, cacheEntry, version );
     
      if ( put && factory.getStatistics().isStatisticsEnabled() ) {
        factory.getStatisticsImplementor().secondLevelCachePut( getPersister().getCacheAccessStrategy().getRegion().getName() );
      }
     
    }

    postInsert();

    if ( factory.getStatistics().isStatisticsEnabled() && !veto ) {
      factory.getStatisticsImplementor()
          .insertEntity( getPersister().getEntityName() );
    }

  }
View Full Code Here

            binding.getJavaType()
        );
      }

      public String getCastType(Class javaType) {
        SessionFactoryImplementor factory =
            ( SessionFactoryImplementor ) entityManager.getFactory().getSessionFactory();
        Type hibernateType = TypeFactory.heuristicType( javaType.getName() );
        if ( hibernateType == null ) {
          throw new IllegalArgumentException(
              "Could not convert java type [" + javaType.getName() + "] to Hibernate type"
          );
        }
        int[] sqlTypeCodes = hibernateType.sqlTypes( factory );
        if ( sqlTypeCodes.length != 1 ) {
          throw new IllegalArgumentException(
              "Invalid Hibernate Type [" + hibernateType.getName() +
                  "] for cast : more than one column spanned"
          );
        }
        return factory.getDialect().getCastTypeName( sqlTypeCodes[0] );
      }
    };

    final RenderedCriteriaQuery renderedCriteriaQuery = criteriaQueryImpl.render( renderingContext );
View Full Code Here

TOP

Related Classes of org.hibernate.engine.SessionFactoryImplementor

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.