Tabnine Logo
SessionImplementor
Code IndexAdd Tabnine to your IDE (free)

How to use
SessionImplementor
in
org.hibernate.engine.spi

Best Java code snippets using org.hibernate.engine.spi.SessionImplementor (Showing top 20 results out of 927)

Refine searchRefine arrow

  • SessionFactoryImplementor
  • PersistenceContext
  • EntityPersister
origin: hibernate/hibernate-orm

  private Object[] getDatabaseSnapshot(SessionImplementor session, EntityPersister persister, Serializable id) {
    if ( persister.isSelectBeforeUpdateRequired() ) {
      Object[] snapshot = session.getPersistenceContext()
          .getDatabaseSnapshot( id, persister );
      if ( snapshot == null ) {
        //do we even really need this? the update will fail anyway....
        if ( session.getFactory().getStatistics().isStatisticsEnabled() ) {
          session.getFactory().getStatistics()
              .optimisticFailure( persister.getEntityName() );
        }
        throw new StaleObjectStateException( persister.getEntityName(), id );
      }
      return snapshot;
    }
    // TODO: optimize away this lookup for entities w/o unsaved-value="undefined"
    final EntityKey entityKey = session.generateEntityKey( id, persister );
    return session.getPersistenceContext().getCachedDatabaseSnapshot( entityKey );
  }
}
origin: hibernate/hibernate-orm

  @Override
  public void doAction(boolean successful, SessionImplementor session) {
    if ( session.isClosed() ) {
      log.trace( "Session was closed; nothing to do" );
      return;
    }

    if ( !successful && session.getTransactionCoordinator().getTransactionCoordinatorBuilder().isJta() ) {
      session.clear();
    }
  }
}
origin: hibernate/hibernate-orm

@Override
public Connection connection() {
  return delegate.connection();
}
origin: hibernate/hibernate-orm

  @Override
  public boolean shouldDoManagedFlush(SessionImplementor session) {
    if ( session.isClosed() ) {
      return false;
    }
    return session.getHibernateFlushMode() != FlushMode.MANUAL;
  }
}
origin: hibernate/hibernate-orm

private static void processDereferencedCollection(PersistentCollection coll, SessionImplementor session) {
  final PersistenceContext persistenceContext = session.getPersistenceContext();
  final CollectionEntry entry = persistenceContext.getCollectionEntry( coll );
  final CollectionPersister loadedPersister = entry.getLoadedPersister();
    Serializable ownerId = loadedPersister.getOwnerEntityPersister().getIdentifier( coll.getOwner(), session );
    if ( ownerId == null ) {
      if ( session.getFactory().getSessionFactoryOptions().isIdentifierRollbackEnabled() ) {
        final EntityEntry ownerEntry = persistenceContext.getEntry( coll.getOwner() );
        if ( ownerEntry != null ) {
          ownerId = ownerEntry.getId();
    final EntityKey key = session.generateEntityKey( ownerId, loadedPersister.getOwnerEntityPersister() );
    final Object owner = persistenceContext.getEntity( key );
    if ( owner == null ) {
      throw new AssertionFailure(
  prepareCollectionForUpdate( coll, entry, session.getFactory() );
origin: hibernate/hibernate-orm

  entityName = source.bestGuessEntityName( entity );
  event.setEntityName( entityName );
final EntityEntry entityEntry = source.getPersistenceContext().getEntry( entity );
EntityState entityState = getEntityState( entity, entityName, entityEntry, source );
if ( entityState == EntityState.DETACHED ) {
  EntityPersister persister = source.getFactory().getEntityPersister( entityName );
  if ( ForeignGenerator.class.isInstance( persister.getIdentifierGenerator() ) ) {
    if ( LOG.isDebugEnabled() && persister.getIdentifier( entity, source ) != null ) {
      LOG.debug( "Resetting entity id attribute to null for foreign generator" );
    persister.setIdentifier( entity, null, source );
    entityState = getEntityState( entity, entityName, entityEntry, source );
origin: com.blazebit/blaze-persistence-integration-hibernate-6.0

@Override
public void afterTransaction(SessionImplementor session, boolean success) {
  TransactionCoordinator coordinator = session.getTransactionCoordinator();
  if (!session.isTransactionInProgress() ) {
    session.getJdbcCoordinator().afterTransaction();
  }
  if (coordinator instanceof JtaTransactionCoordinatorImpl) {
    ((JtaTransactionCoordinatorImpl) coordinator).getSynchronizationCallbackCoordinator().processAnyDelayedAfterCompletion();
  }
}
origin: hibernate/hibernate-orm

  SessionImplementor source) {
if ( !source.getLoadQueryInfluencers().getEnabledFilters().isEmpty()
    && persister.isAffectedByEnabledFilters( source ) ) {
  LOG.trace( "Disregarding cached version (if any) of collection due to enabled filters" );
final boolean useCache = persister.hasCache() && source.getCacheMode().isGetEnabled();
final SessionFactoryImplementor factory = source.getFactory();
final CollectionDataAccess cacheAccessStrategy = persister.getCacheAccessStrategy();
final Object ck = cacheAccessStrategy.generateCacheKey( id, persister, factory, source.getTenantIdentifier() );
final Object ce = CacheHelper.fromSharedCache( source, ck, persister.getCacheAccessStrategy() );
if ( factory.getStatistics().isStatisticsEnabled() ) {
  if ( ce == null ) {
    factory.getStatistics().collectionCacheMiss(
        persister.getNavigableRole(),
        cacheAccessStrategy.getRegion().getName()
    factory.getStatistics().collectionCacheHit(
        persister.getNavigableRole(),
        cacheAccessStrategy.getRegion().getName()
);
final PersistenceContext persistenceContext = source.getPersistenceContext();
cacheEntry.assemble( collection, persister, persistenceContext.getCollectionOwner( id, persister ) );
persistenceContext.getCollectionEntry( collection ).postInitialize( collection );
origin: hibernate/hibernate-orm

/**
 * Obtain a lob creator for the given session.
 *
 * @param session The session for which to obtain a lob creator
 *
 * @return The log creator reference
 */
public static LobCreator getLobCreator(SessionImplementor session) {
  return session.getFactory()
      .getServiceRegistry()
      .getService( JdbcServices.class )
      .getLobCreator( session );
}
origin: hibernate/hibernate-orm

/**
 * make sure user didn't mangle the id
 */
public void checkId(Object object, EntityPersister persister, Serializable id, SessionImplementor session)
    throws HibernateException {
  if ( id != null && id instanceof DelayedPostInsertIdentifier ) {
    // this is a situation where the entity id is assigned by a post-insert generator
    // and was saved outside the transaction forcing it to be delayed
    return;
  }
  if ( persister.canExtractIdOutOfEntity() ) {
    Serializable oid = persister.getIdentifier( object, session );
    if ( id == null ) {
      throw new AssertionFailure( "null id in " + persister.getEntityName() + " entry (don't flush the Session after an exception occurs)" );
    }
    if ( !persister.getIdentifierType().isEqual( id, oid, session.getFactory() ) ) {
      throw new HibernateException(
          "identifier of an instance of " + persister.getEntityName() + " was altered from "
              + id + " to " + oid
      );
    }
  }
}
origin: hibernate/hibernate-orm

assertTrue( ( (SessionImplementor) session ).getPersistenceContext().containsEntity(
        new EntityKey(
            ( (SessionImplementor) session ).getContextEntityIdentifier( a2.getB() ),
            ( (SessionImplementor) session ).getFactory().getEntityPersister( B.class.getName() )
origin: hibernate/hibernate-orm

protected boolean invokeInterceptor(
    SessionImplementor session,
    Object entity,
    EntityEntry entry,
    final Object[] values,
    EntityPersister persister) {
  boolean isDirty = false;
  if ( entry.getStatus() != Status.DELETED ) {
    if ( callbackRegistry.preUpdate( entity ) ) {
      isDirty = copyState( entity, persister.getPropertyTypes(), values, session.getFactory() );
    }
  }
  final boolean answerFromInterceptor =  session.getInterceptor().onFlushDirty(
      entity,
      entry.getId(),
      values,
      entry.getLoadedState(),
      persister.getPropertyNames(),
      persister.getPropertyTypes()
  );
  return answerFromInterceptor || isDirty;
}
origin: stackoverflow.com

 CriteriaImpl criteriaImpl = (CriteriaImpl)criteria;
SessionImplementor session = criteriaImpl.getSession();
SessionFactoryImplementor factory = session.getFactory();
CriteriaQueryTranslator translator=new CriteriaQueryTranslator(factory,criteriaImpl,criteriaImpl.getEntityOrClassName(),CriteriaQueryTranslator.ROOT_SQL_ALIAS);
String[] implementors = factory.getImplementors( criteriaImpl.getEntityOrClassName() );

CriteriaJoinWalker walker = new CriteriaJoinWalker((OuterJoinLoadable)factory.getEntityPersister(implementors[0]), 
            translator,
            factory, 
            criteriaImpl, 
            criteriaImpl.getEntityOrClassName(), 
            session.getLoadQueryInfluencers()   );

String sql=walker.getSQLString();
origin: hibernate/hibernate-orm

protected CollectionPersister resolveCollectionPersister(
    SessionImplementor session,
    PersistentCollection collection) {
  // First attempt to resolve the persister from the collection entry
  if ( collection != null ) {
    CollectionEntry collectionEntry = session.getPersistenceContext().getCollectionEntry( collection );
    if ( collectionEntry != null ) {
      CollectionPersister collectionPersister = collectionEntry.getCurrentPersister();
      if ( collectionPersister != null ) {
        return collectionPersister;
      }
    }
  }
  // Fallback to resolving the persister from the collection role
  final CollectionPersister collectionPersister = session.getFactory()
      .getMetamodel()
      .collectionPersister( commonCollectionMapperData.getRole() );
  if ( collectionPersister == null ) {
    throw new AuditException(
        String.format(
            Locale.ROOT,
            "Failed to locate CollectionPersister for collection [%s]",
            commonCollectionMapperData.getRole()
        )
    );
  }
  return collectionPersister;
}
origin: hibernate/hibernate-orm

  /**
   * Create Hibernate proxy or retrieve the complete object of referenced, not audited entity. According to
   * {@link org.hibernate.envers.Audited#targetAuditMode()}} documentation, reference shall point to current
   * (non-historical) version of an entity.
   */
  private Object createNotAuditedEntityReference(
      AuditReaderImplementor versionsReader, Class<?> entityClass,
      String entityName, Serializable primaryKey) {
    final EntityPersister entityPersister = versionsReader.getSessionImplementor().getFactory().getMetamodel()
        .entityPersister( entityName );
    if ( entityPersister.hasProxy() ) {
      // If possible create a proxy. Returning complete object may affect performance.
      return versionsReader.getSession().load( entityClass, primaryKey );
    }
    else {
      // If proxy is not allowed (e.g. @Proxy(lazy=false)) construct the original object.
      return versionsReader.getSession().get( entityClass, primaryKey );
    }
  }
}
origin: hibernate/hibernate-orm

Object entity = source.getPersistenceContext().unproxyAndReassociate( event.getObject() );
EntityEntry entry = source.getPersistenceContext().getEntry(entity);
if (entry==null) {
  final EntityPersister persister = source.getEntityPersister( event.getEntityName(), entity );
  final Serializable id = persister.getIdentifier( entity, source );
  if ( !ForeignKeys.isNotTransient( event.getEntityName(), entity, Boolean.FALSE, source ) ) {
    throw new TransientObjectException(
        "cannot lock an unsaved transient instance: " +
        persister.getEntityName()
    );
origin: hibernate/hibernate-orm

public AddWorkUnit(
    SessionImplementor sessionImplementor,
    String entityName,
    EnversService enversService,
    Serializable id,
    Map<String, Object> data) {
  super( sessionImplementor, entityName, enversService, id, RevisionType.ADD );
  this.data = data;
  final String[] propertyNames = sessionImplementor.getFactory().getMetamodel()
      .entityPersister( getEntityName() )
      .getPropertyNames();
  this.state = ArraysTools.mapToArray( data, propertyNames );
}
origin: hibernate/hibernate-orm

private static void checkInBatchFetchQueue(long id, Session session, boolean expected) {
  final SessionImplementor sessionImplementor = (SessionImplementor) session;
  final EntityPersister persister =
      sessionImplementor.getFactory().getMetamodel().entityPersister( Task.class );
  final BatchFetchQueue batchFetchQueue =
      sessionImplementor.getPersistenceContext().getBatchFetchQueue();
  assertEquals( expected, batchFetchQueue.containsEntityKey( new EntityKey( id, persister ) ) );
}
origin: hibernate/hibernate-orm

CollectionPersister persister = session.getFactory().getCollectionPersister( collectionType.getRole() );
final PersistenceContext persistenceContext = session.getPersistenceContext();
  PersistentCollection ah = persistenceContext.getCollectionHolder( collection );
  if ( ah == null ) {
    ah = collectionType.wrap( session, collection );
    persistenceContext.addNewCollection( persister, ah );
    persistenceContext.addCollectionHolder( ah );
origin: org.hibernate/com.springsource.org.hibernate

@Override
protected CollectionInitializer createSubselectInitializer(SubselectFetch subselect, SessionImplementor session) {
  return new SubselectOneToManyLoader( 
      this,
      subselect.toSubselectString( getCollectionType().getLHSPropertyName() ),
      subselect.getResult(),
      subselect.getQueryParameters(),
      subselect.getNamedParameterLocMap(),
      session.getFactory(),
      session.getLoadQueryInfluencers()
    );
}
org.hibernate.engine.spiSessionImplementor

Javadoc

Defines the "internal contract" for Session and other parts of Hibernate such as org.hibernate.type.Type, org.hibernate.persister.entity.EntityPersisterand org.hibernate.persister.collection.CollectionPersister implementations. A Session, through this interface and SharedSessionContractImplementor, implements:
  • org.hibernate.resource.jdbc.spi.JdbcSessionOwner to drive the behavior of the org.hibernate.resource.jdbc.spi.JdbcSessionContext delegate
  • TransactionCoordinatorBuilder.Optionsto drive the creation of the TransactionCoordinator delegate
  • org.hibernate.engine.jdbc.LobCreationContext to act as the context for JDBC LOB instance creation
  • org.hibernate.type.descriptor.WrapperOptions to fulfill the behavior needed while binding/extracting values to/from JDBC as part of the Type contracts
See also org.hibernate.event.spi.EventSource which extends this interface providing bridge to the event generation features of org.hibernate.event

Most used methods

  • getFactory
    Get the creating SessionFactoryImplementor
  • getTransactionCoordinator
  • connection
  • getPersistenceContext
    Get the persistence context for this session
  • getLoadQueryInfluencers
    Get the load query influencers associated with this session.
  • isTransactionInProgress
    Does this Session have an active Hibernate transaction or is there a JTA transaction in progress?
  • getEntityPersister
    Get the EntityPersister for any instance
  • getJdbcCoordinator
  • isClosed
    Determine whether the session is closed. Provided separately from #isOpen() as this method does not
  • flush
  • getTenantIdentifier
    Match te method on org.hibernate.Session and org.hibernate.StatelessSession
  • generateEntityKey
  • getTenantIdentifier,
  • generateEntityKey,
  • getContextEntityIdentifier,
  • isOpen,
  • bestGuessEntityName,
  • getFlushMode,
  • getSessionFactory,
  • guessEntityName,
  • immediateLoad,
  • initializeCollection

Popular in Java

  • Start an intent from android
  • getApplicationContext (Context)
  • compareTo (BigDecimal)
  • addToBackStack (FragmentTransaction)
  • Graphics2D (java.awt)
    This Graphics2D class extends the Graphics class to provide more sophisticated control overgraphics
  • File (java.io)
    An "abstract" representation of a file system entity identified by a pathname. The pathname may be a
  • KeyStore (java.security)
    KeyStore is responsible for maintaining cryptographic keys and their owners. The type of the syste
  • GregorianCalendar (java.util)
    GregorianCalendar is a concrete subclass of Calendarand provides the standard calendar used by most
  • Vector (java.util)
    Vector is an implementation of List, backed by an array and synchronized. All optional operations in
  • AtomicInteger (java.util.concurrent.atomic)
    An int value that may be updated atomically. See the java.util.concurrent.atomic package specificati
  • Top plugins for Android Studio
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now