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.getCache().insert( ck, cacheEntry, version );
     
      if ( put && factory.getStatistics().isStatisticsEnabled() ) {
        factory.getStatisticsImplementor()
            .secondLevelCachePut( getPersister().getCache().getRegionName() );
      }
     
    }

    postInsert();

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

  }
View Full Code Here


  public Object readFrom(ResultSet rs, CollectionPersister persister, CollectionAliases descriptor, Object owner)
  throws HibernateException, SQLException {
    Object object = persister.readElement( rs, owner, descriptor.getSuffixedElementAliases(), getSession() );
    final Type elementType = persister.getElementType();
    final SessionFactoryImplementor factory = persister.getFactory();
    String indexNode = getIndexAttributeName(persister);

    Element elem = element.addElement( persister.getElementNodeName() );
    elementType.setToXMLNode( elem, object, factory );
   
View Full Code Here

      if ( entityEntry.getStatus() == Status.DELETED ) {
        throw new AssertionFailure( "entity was deleted" );
      }

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

      Serializable requestedId = event.getRequestedId();

      Serializable savedId;
      if ( requestedId == null ) {
View Full Code Here

   * @param session The session from which the request is originating.
   * @return The iterator.
   */
  public Iterator getElementsIterator(Object collection, SessionImplementor session) {
    if ( session.getEntityMode()==EntityMode.DOM4J ) {
      final SessionFactoryImplementor factory = session.getFactory();
      final CollectionPersister persister = factory.getCollectionPersister( getRole() );
      final Type elementType = persister.getElementType();
     
      List elements = ( (Element) collection ).elements( persister.getElementNodeName() );
      ArrayList results = new ArrayList();
      for ( int i=0; i<elements.size(); i++ ) {
View Full Code Here

  public Object loadByUniqueKey(
      String entityName,
      String uniqueKeyPropertyName,
      Object key,
      SessionImplementor session) throws HibernateException {
    final SessionFactoryImplementor factory = session.getFactory();
    UniqueKeyLoadable persister = ( UniqueKeyLoadable ) factory.getEntityPersister( entityName );

    //TODO: implement caching?! proxies?!

    EntityUniqueKey euk = new EntityUniqueKey(
        entityName,
View Full Code Here

    if ( !useCache ) {
      return false;
    }
    else {
     
      final SessionFactoryImplementor factory = source.getFactory();

      final CacheKey ck = new CacheKey(
          id,
          persister.getKeyType(),
          persister.getRole(),
          source.getEntityMode(),
          source.getFactory()
        );
      Object ce = persister.getCache().get( ck, source.getTimestamp() );
     
      if ( factory.getStatistics().isStatisticsEnabled() ) {
        if (ce==null) {
          factory.getStatisticsImplementor().secondLevelCacheMiss(
              persister.getCache().getRegionName()
            );
        }
        else {
          factory.getStatisticsImplementor().secondLevelCacheHit(
              persister.getCache().getRegionName()
            );
        }

       
View Full Code Here

          SessionImplementor session) throws StaleObjectStateException, JDBCException {
    if ( !lockable.isVersioned() ) {
      throw new HibernateException( "write locks via update not supported for non-versioned entities [" + lockable.getEntityName() + "]" );
    }
    // todo : should we additionally check the current isolation mode explicitly?
    SessionFactoryImplementor factory = session.getFactory();
    try {
      PreparedStatement st = session.getBatcher().prepareSelectStatement( sql );
      try {
        lockable.getVersionType().nullSafeSet( st, version, 1, session );
        int offset = 2;

        lockable.getIdentifierType().nullSafeSet( st, id, offset, session );
        offset += lockable.getIdentifierType().getColumnSpan( factory );

        if ( lockable.isVersioned() ) {
          lockable.getVersionType().nullSafeSet( st, version, offset, session );
        }

        int affected = st.executeUpdate();
        if ( affected < 0 ) {
          factory.getStatisticsImplementor().optimisticFailure( lockable.getEntityName() );
          throw new StaleObjectStateException( lockable.getEntityName(), id );
        }

      }
      finally {
View Full Code Here

      );
    }
  }

  protected String generateLockString() {
    SessionFactoryImplementor factory = lockable.getFactory();
    Update update = new Update( factory.getDialect() );
    update.setTableName( lockable.getRootTableName() );
    update.setPrimaryKeyColumnNames( lockable.getRootTableIdentifierColumnNames() );
    update.setVersionColumnName( lockable.getVersionColumnName() );
    update.addColumn( lockable.getVersionColumnName() );
    if ( factory.getSettings().isCommentsEnabled() ) {
      update.setComment( lockMode + " lock " + lockable.getEntityName() );
    }
    return update.toStatementString();
  }
View Full Code Here

          Serializable id,
          Object version,
          Object object,
          SessionImplementor session) throws StaleObjectStateException, JDBCException {

    SessionFactoryImplementor factory = session.getFactory();
    try {
      PreparedStatement st = session.getBatcher().prepareSelectStatement( sql );
      try {
        lockable.getIdentifierType().nullSafeSet( st, id, 1, session );
        if ( lockable.isVersioned() ) {
          lockable.getVersionType().nullSafeSet(
              st,
              version,
              lockable.getIdentifierType().getColumnSpan( factory ) + 1,
              session
          );
        }

        ResultSet rs = st.executeQuery();
        try {
          if ( !rs.next() ) {
            if ( factory.getStatistics().isStatisticsEnabled() ) {
              factory.getStatisticsImplementor()
                  .optimisticFailure( lockable.getEntityName() );
            }
            throw new StaleObjectStateException( lockable.getEntityName(), id );
          }
        }
View Full Code Here

  protected LockMode getLockMode() {
    return lockMode;
  }

  protected String generateLockString() {
    SessionFactoryImplementor factory = lockable.getFactory();
    SimpleSelect select = new SimpleSelect( factory.getDialect() )
        .setLockMode( lockMode )
        .setTableName( lockable.getRootTableName() )
        .addColumn( lockable.getRootTableIdentifierColumnNames()[0] )
        .addCondition( lockable.getRootTableIdentifierColumnNames(), "=?" );
    if ( lockable.isVersioned() ) {
      select.addCondition( lockable.getVersionColumnName(), "=?" );
    }
    if ( factory.getSettings().isCommentsEnabled() ) {
      select.setComment( lockMode + " lock " + lockable.getEntityName() );
    }
    return select.toStatementString();
  }
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.