Tabnine Logo
CollectionEntry.getLoadedPersister
Code IndexAdd Tabnine to your IDE (free)

How to use
getLoadedPersister
method
in
org.hibernate.engine.spi.CollectionEntry

Best Java code snippets using org.hibernate.engine.spi.CollectionEntry.getLoadedPersister (Showing top 20 results out of 315)

origin: hibernate/hibernate-orm

/**
 * After a collection was initialized or evicted, we don't
 * need to batch fetch it anymore, remove it from the queue
 * if necessary
 */
public void removeBatchLoadableCollection(CollectionEntry ce) {
  LinkedHashMap<CollectionEntry, PersistentCollection> map =  batchLoadableCollections.get( ce.getLoadedPersister().getRole() );
  if ( map != null ) {
    map.remove( ce );
  }
}
origin: hibernate/hibernate-orm

/**
 * If a CollectionEntry represents a batch loadable collection, add
 * it to the queue.
 */
public void addBatchLoadableCollection(PersistentCollection collection, CollectionEntry ce) {
  final CollectionPersister persister = ce.getLoadedPersister();
  LinkedHashMap<CollectionEntry, PersistentCollection> map =  batchLoadableCollections.get( persister.getRole() );
  if ( map == null ) {
    map = new LinkedHashMap<>( 16 );
    batchLoadableCollections.put( persister.getRole(), map );
  }
  map.put( ce, collection );
}

origin: hibernate/hibernate-orm

/**
 * Is this the "inverse" end of a bidirectional one-to-many, or
 * of a collection with no orphan delete?
 */
@SuppressWarnings({"JavaDoc"})
protected boolean isInverseOneToManyOrNoOrphanDelete() {
  final CollectionEntry ce = session.getPersistenceContext().getCollectionEntry( this );
  return ce != null
      && ce.getLoadedPersister().isInverse()
      && ( ce.getLoadedPersister().isOneToMany() || !ce.getLoadedPersister().hasOrphanDelete() );
}
origin: hibernate/hibernate-orm

@Override
public Object getLoadedCollectionOwnerOrNull(PersistentCollection collection) {
  final CollectionEntry ce = getCollectionEntry( collection );
  if ( ce.getLoadedPersister() == null ) {
    return null;
  }
  Object loadedOwner = null;
  // TODO: an alternative is to check if the owner has changed; if it hasn't then
  // return collection.getOwner()
  final Serializable entityId = getLoadedCollectionOwnerIdOrNull( ce );
  if ( entityId != null ) {
    loadedOwner = getCollectionOwner( entityId, ce.getLoadedPersister() );
  }
  return loadedOwner;
}
origin: hibernate/hibernate-orm

/**
 * Is this the "inverse" end of a bidirectional association with
 * no orphan delete enabled?
 */
@SuppressWarnings({"JavaDoc"})
protected boolean isInverseCollectionNoOrphanDelete() {
  final CollectionEntry ce = session.getPersistenceContext().getCollectionEntry( this );
  return ce != null
      &&
      ce.getLoadedPersister().isInverse() &&
      !ce.getLoadedPersister().hasOrphanDelete();
}
origin: hibernate/hibernate-orm

public boolean isSnapshotEmpty(PersistentCollection collection) {
  //TODO: does this really need to be here?
  //      does the collection already have
  //      it's own up-to-date snapshot?
  return collection.wasInitialized() &&
    ( getLoadedPersister()==null || getLoadedPersister().isMutable() ) &&
    collection.isSnapshotEmpty( getSnapshot() );
}
origin: hibernate/hibernate-orm

protected static CollectionPersister getLoadedCollectionPersister( PersistentCollection collection, EventSource source ) {
  CollectionEntry ce = source.getPersistenceContext().getCollectionEntry( collection );
  return ( ce == null ? null : ce.getLoadedPersister() );		
}
origin: hibernate/hibernate-orm

/**
 * Get the ID for the entity that owned this persistent collection when it was loaded
 *
 * @param ce The collection entry
 * @return the owner ID if available from the collection's loaded key; otherwise, returns null
 */
private Serializable getLoadedCollectionOwnerIdOrNull(CollectionEntry ce) {
  if ( ce == null || ce.getLoadedKey() == null || ce.getLoadedPersister() == null ) {
    return null;
  }
  // TODO: an alternative is to check if the owner has changed; if it hasn't then
  // get the ID from collection.getOwner()
  return ce.getLoadedPersister().getCollectionType().getIdOfOwnerOrNull( ce.getLoadedKey(), session );
}
origin: hibernate/hibernate-orm

/**
 * Determine if the collection is "really" dirty, by checking dirtiness
 * of the collection elements, if necessary
 */
private void dirty(PersistentCollection collection) throws HibernateException {
  boolean forceDirty = collection.wasInitialized() &&
      !collection.isDirty() && //optimization
      getLoadedPersister() != null &&
      getLoadedPersister().isMutable() && //optimization
      ( collection.isDirectlyAccessible() || getLoadedPersister().getElementType().isMutable() ) && //optimization
      !collection.equalsSnapshot( getLoadedPersister() );
  if ( forceDirty ) {
    collection.dirty();
  }
}
origin: hibernate/hibernate-orm

public void postInitialize(PersistentCollection collection) throws HibernateException {
  snapshot = getLoadedPersister().isMutable()
      ? collection.getSnapshot( getLoadedPersister() )
      : null;
  collection.setSnapshot(loadedKey, role, snapshot);
  if ( getLoadedPersister().getBatchSize() > 1 ) {
    ( (AbstractPersistentCollection) collection ).getSession()
        .getPersistenceContext()
        .getBatchFetchQueue()
        .removeBatchLoadableCollection( this );
  }
}
origin: hibernate/hibernate-orm

/**
 * Is this the "inverse" end of a bidirectional association?
 */
@SuppressWarnings({"JavaDoc"})
protected boolean isInverseCollection() {
  final CollectionEntry ce = session.getPersistenceContext().getCollectionEntry( this );
  return ce != null && ce.getLoadedPersister().isInverse();
}
origin: hibernate/hibernate-orm

private void evictCollection(PersistentCollection collection) {
  CollectionEntry ce = (CollectionEntry) getSession().getPersistenceContext().getCollectionEntries().remove(collection);
  if ( LOG.isDebugEnabled() ) {
    LOG.debugf(
        "Evicting collection: %s",
        MessageHelper.collectionInfoString( ce.getLoadedPersister(),
            collection,
            ce.getLoadedKey(),
            getSession() ) );
  }
  if (ce.getLoadedPersister() != null && ce.getLoadedPersister().getBatchSize() > 1) {
    getSession().getPersistenceContext().getBatchFetchQueue().removeBatchLoadableCollection(ce);
  }
  if ( ce.getLoadedPersister() != null && ce.getLoadedKey() != null ) {
    //TODO: is this 100% correct?
    getSession().getPersistenceContext().getCollectionsByKey().remove(
        new CollectionKey( ce.getLoadedPersister(), ce.getLoadedKey() )
    );
  }
}

origin: hibernate/hibernate-orm

  @Override
  public void onPostRecreateCollection(PostCollectionRecreateEvent event) {
    final CollectionEntry collectionEntry = getCollectionEntry( event );
    if ( !collectionEntry.getLoadedPersister().isInverse() ) {
      onCollectionAction( event, event.getCollection(), null, collectionEntry );
    }
    else {
      onCollectionActionInversed( event, event.getCollection(), null, collectionEntry );
    }
  }
}
origin: hibernate/hibernate-orm

protected final void onCollectionActionInversed(
    AbstractCollectionEvent event,
    PersistentCollection newColl,
    Serializable oldColl,
    CollectionEntry collectionEntry) {
  if ( shouldGenerateRevision( event ) ) {
    final String entityName = event.getAffectedOwnerEntityName();
    final String ownerEntityName = ( (AbstractCollectionPersister) collectionEntry.getLoadedPersister() ).getOwnerEntityName();
    final String referencingPropertyName = collectionEntry.getRole().substring( ownerEntityName.length() + 1 );
    final RelationDescription rd = searchForRelationDescription( entityName, referencingPropertyName );
    if ( rd != null ) {
      if ( rd.getRelationType().equals( RelationType.TO_MANY_NOT_OWNING ) && rd.isIndexed() ) {
        onCollectionAction( event, newColl, oldColl, collectionEntry );
      }
    }
  }
}
origin: hibernate/hibernate-orm

private static void processNeverReferencedCollection(PersistentCollection coll, SessionImplementor session)
    throws HibernateException {
  final PersistenceContext persistenceContext = session.getPersistenceContext();
  final CollectionEntry entry = persistenceContext.getCollectionEntry( coll );
  if ( LOG.isDebugEnabled() ) {
    LOG.debugf(
        "Found collection with unloaded owner: %s",
        MessageHelper.collectionInfoString( 
            entry.getLoadedPersister(),
            coll,
            entry.getLoadedKey(),
            session
        )
    );
  }
  entry.setCurrentPersister( entry.getLoadedPersister() );
  entry.setCurrentKey( entry.getLoadedKey() );
  prepareCollectionForUpdate( coll, entry, session.getFactory() );
}
origin: hibernate/hibernate-orm

  @Override
  public void onPreUpdateCollection(PreCollectionUpdateEvent event) {
    final CollectionEntry collectionEntry = getCollectionEntry( event );
    if ( !collectionEntry.getLoadedPersister().isInverse() ) {
      onCollectionAction( event, event.getCollection(), collectionEntry.getSnapshot(), collectionEntry );
    }
    else {
      onCollectionActionInversed( event, event.getCollection(), collectionEntry.getSnapshot(), collectionEntry );
    }
  }
}
origin: hibernate/hibernate-orm

  @Override
  public Boolean doWork() {
    final CollectionEntry entry = session.getPersistenceContext().getCollectionEntry( AbstractPersistentCollection.this );
    final CollectionPersister persister = entry.getLoadedPersister();
    if ( persister.isExtraLazy() ) {
      if ( hasQueuedOperations() ) {
        session.flush();
      }
      return persister.indexExists( entry.getLoadedKey(), index, session );
    }
    else {
      read();
    }
    return null;
  }
}
origin: hibernate/hibernate-orm

  @Override
  public Boolean doWork() {
    final CollectionEntry entry = session.getPersistenceContext().getCollectionEntry( AbstractPersistentCollection.this );
    final CollectionPersister persister = entry.getLoadedPersister();
    if ( persister.isExtraLazy() ) {
      if ( hasQueuedOperations() ) {
        session.flush();
      }
      return persister.elementExists( entry.getLoadedKey(), element, session );
    }
    else {
      read();
    }
    return null;
  }
}
origin: hibernate/hibernate-orm

  @Override
  public Boolean doWork() {
    final CollectionEntry entry = session.getPersistenceContext().getCollectionEntry( AbstractPersistentCollection.this );
    if ( entry != null ) {
      final CollectionPersister persister = entry.getLoadedPersister();
      if ( persister.isExtraLazy() ) {
        if ( hasQueuedOperations() ) {
          session.flush();
        }
        cachedSize = persister.getSize( entry.getLoadedKey(), session );
        return true;
      }
      else {
        read();
      }
    }
    else{
      throwLazyInitializationExceptionIfNotConnected();
    }
    return false;
  }
}
origin: hibernate/hibernate-orm

  @Override
  public void onPreRemoveCollection(PreCollectionRemoveEvent event) {
    final CollectionEntry collectionEntry = getCollectionEntry( event );
    if ( collectionEntry != null ) {
      if ( !collectionEntry.getLoadedPersister().isInverse() ) {
        Serializable oldColl = collectionEntry.getSnapshot();
        if ( !event.getCollection().wasInitialized() && shouldGenerateRevision( event ) ) {
          // In case of uninitialized collection we need a fresh snapshot to properly calculate audit data.
          oldColl = initializeCollection( event );
        }
        onCollectionAction( event, null, oldColl, collectionEntry );
      }
      else {
        // HHH-7510 - Avoid LazyInitializationException when global_with_modified_flag = true
        if ( getEnversService().getGlobalConfiguration().isGlobalWithModifiedFlag() ) {
          initializeCollection( event );
        }
      }
    }
  }
}
org.hibernate.engine.spiCollectionEntrygetLoadedPersister

Javadoc

This is only available late during the flush cycle

Popular methods of CollectionEntry

  • getSnapshot
  • getLoadedKey
  • getOrphans
    Get the collection orphans (entities which were removed from the collection)
  • <init>
    For newly wrapped collections, or dereferenced collection wrappers
  • afterAction
    Called after execution of an action
  • afterDeserialize
  • deserialize
    Custom deserialization routine used during deserialization of a Session/PersistenceContext for incre
  • dirty
    Determine if the collection is "really" dirty, by checking dirtiness of the collection elements, if
  • getCurrentKey
    This is only available late during the flush cycle
  • getCurrentPersister
  • getRole
  • isDorecreate
  • getRole,
  • isDorecreate,
  • isDoremove,
  • isDoupdate,
  • isIgnore,
  • isProcessed,
  • isReached,
  • isSnapshotEmpty,
  • postFlush

Popular in Java

  • Finding current android device location
  • setContentView (Activity)
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • setScale (BigDecimal)
  • FileOutputStream (java.io)
    An output stream that writes bytes to a file. If the output file exists, it can be replaced or appen
  • InputStream (java.io)
    A readable source of bytes.Most clients will use input streams that read data from the file system (
  • ResultSet (java.sql)
    An interface for an object which represents a database table entry, returned as the result of the qu
  • UUID (java.util)
    UUID is an immutable representation of a 128-bit universally unique identifier (UUID). There are mul
  • Vector (java.util)
    Vector is an implementation of List, backed by an array and synchronized. All optional operations in
  • Executors (java.util.concurrent)
    Factory and utility methods for Executor, ExecutorService, ScheduledExecutorService, ThreadFactory,
  • Github Copilot alternatives
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