Package org.hibernate.persister.entity

Examples of org.hibernate.persister.entity.EntityPersister


    final PersistenceContext persistenceContext = source.getPersistenceContext();

    if ( object instanceof HibernateProxy ) {
      LazyInitializer li = ( (HibernateProxy) object ).getHibernateLazyInitializer();
      Serializable id = li.getIdentifier();
      EntityPersister persister = source.getFactory().getEntityPersister( li.getEntityName() );
      if ( id == null ) {
        throw new IllegalArgumentException("null identifier");
      }

      EntityKey key = new EntityKey( id, persister, source.getEntityMode() );
View Full Code Here


            entry.getId(),
            entry.getPersister().getEntityName()
        );
      }

      final EntityPersister persister = entry.getPersister();

      if ( log.isTraceEnabled() )
        log.trace(
            "locking " +
            MessageHelper.infoString( persister, entry.getId(), source.getFactory() ) +
            " in mode: " +
            requestedLockMode
        );

      final SoftLock lock;
      final CacheKey ck;
      if ( persister.hasCache() ) {
        ck = new CacheKey(
            entry.getId(),
            persister.getIdentifierType(),
            persister.getRootEntityName(),
            source.getEntityMode(),
            source.getFactory()
        );
        lock = persister.getCacheAccessStrategy().lockItem( ck, entry.getVersion() );
      }
      else {
        ck = null;
        lock = null;
      }
     
      try {
        if ( persister.isVersioned() && requestedLockMode == LockMode.FORCE ) {
          // todo : should we check the current isolation mode explicitly?
          Object nextVersion = persister.forceVersionIncrement(
              entry.getId(), entry.getVersion(), source
          );
          entry.forceLocked( object, nextVersion );
        }
        else {
          persister.lock( entry.getId(), entry.getVersion(), object, requestedLockMode, source );
        }
        entry.setLockMode(requestedLockMode);
      }
      finally {
        // the database now holds a lock + the object is flushed from the cache,
        // so release the soft lock
        if ( persister.hasCache() ) {
          persister.getCacheAccessStrategy().unlockItem( ck, lock );
        }
      }

    }
  }
View Full Code Here

      Object entity,
      String entityName,
      Object anything,
      EventSource source,
      boolean requiresImmediateIdAccess) {
    EntityPersister persister = source.getEntityPersister( entityName, entity );
    Serializable generatedId = persister.getIdentifierGenerator().generate( source, entity );
    if ( generatedId == null ) {
      throw new IdentifierGenerationException( "null id generated for:" + entity.getClass() );
    }
    else if ( generatedId == IdentifierGeneratorFactory.SHORT_CIRCUIT_INDICATOR ) {
      return source.getIdentifier( entity );
    }
    else if ( generatedId == IdentifierGeneratorFactory.POST_INSERT_INDICATOR ) {
      return performSave( entity, null, persister, true, anything, source, requiresImmediateIdAccess );
    }
    else {

      if ( log.isDebugEnabled() ) {
        log.debug(
            "generated identifier: " +
                persister.getIdentifierType().toLoggableString( generatedId, source.getFactory() ) +
                ", using strategy: " +
                persister.getIdentifierGenerator().getClass().getName()
            //TODO: define toString()s for generators
        );
      }

      return performSave( entity, generatedId, persister, false, anything, source, true );
View Full Code Here

          accessStrategy = entityRegion.buildAccessStrategy( accessType );
          entityAccessStrategies.put( cacheRegionName, accessStrategy );
          allCacheRegions.put( cacheRegionName, entityRegion );
        }
      }
      EntityPersister cp = PersisterFactory.createClassPersister( model, accessStrategy, this, mapping );
      entityPersisters.put( model.getEntityName(), cp );
      classMeta.put( model.getEntityName(), cp.getClassMetadata() );
    }
    classMetadata = Collections.unmodifiableMap(classMeta);

    Map tmpEntityToCollectionRoleMap = new HashMap();
    collectionPersisters = new HashMap();
View Full Code Here

    }
    return currentSessionContext.currentSession();
  }

  public EntityPersister getEntityPersister(String entityName) throws MappingException {
    EntityPersister result = (EntityPersister) entityPersisters.get(entityName);
    if (result==null) {
      throw new MappingException( "Unknown entity: " + entityName );
    }
    return result;
  }
View Full Code Here

    ArrayList results = new ArrayList();
    Iterator iter = entityPersisters.values().iterator();
    while ( iter.hasNext() ) {
      //test this entity to see if we must query it
      EntityPersister testPersister = (EntityPersister) iter.next();
      if ( testPersister instanceof Queryable ) {
        Queryable testQueryable = (Queryable) testPersister;
        String testClassName = testQueryable.getEntityName();
        boolean isMappedClass = className.equals(testClassName);
        if ( testQueryable.isExplicitPolymorphism() ) {
View Full Code Here

    isClosed = true;

    Iterator iter = entityPersisters.values().iterator();
    while ( iter.hasNext() ) {
      EntityPersister p = (EntityPersister) iter.next();
      if ( p.hasCache() ) {
        p.getCacheAccessStrategy().getRegion().destroy();
      }
    }

    iter = collectionPersisters.values().iterator();
    while ( iter.hasNext() ) {
      CollectionPersister p = (CollectionPersister) iter.next();
      if ( p.hasCache() ) {
        p.getCacheAccessStrategy().getRegion().destroy();
      }
    }

    if ( settings.isQueryCacheEnabled() )  {
      queryCache.destroy();
View Full Code Here

    observer.sessionFactoryClosed( this );
    eventListeners.destroyListeners();
  }

  public void evictEntity(String entityName, Serializable id) throws HibernateException {
    EntityPersister p = getEntityPersister( entityName );
    if ( p.hasCache() ) {
      if ( log.isDebugEnabled() ) {
        log.debug( "evicting second-level cache: " + MessageHelper.infoString(p, id, this) );
      }
      CacheKey cacheKey = new CacheKey( id, p.getIdentifierType(), p.getRootEntityName(), EntityMode.POJO, this );
      p.getCacheAccessStrategy().evict( cacheKey );
    }
  }
View Full Code Here

      if ( parentFromElement != null ) {
        return createFromElementInSubselect( path, pathAlias, parentFromElement, classAlias );
      }
    }

    EntityPersister entityPersister = fromClause.getSessionFactoryHelper().requireClassPersister( path );

    FromElement elem = createAndAddFromElement( path,
        classAlias,
        entityPersister,
        ( EntityType ) ( ( Queryable ) entityPersister ).getType(),
        null );

    // Add to the query spaces.
    fromClause.getWalker().addQuerySpaces( entityPersister.getQuerySpaces() );

    return elem;
  }
View Full Code Here

    if ( log.isDebugEnabled() ) {
      log.debug( "createFromElementInSubselect() : path = " + path );
    }
    // Create an DotNode AST for the path and resolve it.
    FromElement fromElement = evaluateFromElementPath( path, classAlias );
    EntityPersister entityPersister = fromElement.getEntityPersister();

    // If the first identifier in the path referrs to the class alias (not the class name), then this
    // is a correlated subselect.  If it's a correlated sub-select, use the existing table alias.  Otherwise
    // generate a new one.
    String tableAlias = null;
View Full Code Here

TOP

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

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.