Package org.hibernate.engine.spi

Examples of org.hibernate.engine.spi.EntityKey


      LoadEvent event,
      LoadEventListener.LoadType options,
      EntityPersister dependentPersister,
      EmbeddedComponentType dependentIdType,
      EntityPersister parentPersister) {
    final EntityKey parentEntityKey = event.getSession().generateEntityKey( event.getEntityId(), parentPersister );
    final Object parent = doLoad( event, parentPersister, parentEntityKey, options );

    final Serializable dependent = (Serializable) dependentIdType.instantiate( parent, event.getSession() );
    dependentIdType.setPropertyValues( dependent, new Object[] {parent}, dependentPersister.getEntityMode() );
    final EntityKey dependentEntityKey = event.getSession().generateEntityKey( dependent, dependentPersister );
    event.setEntityId( dependent );

    event.setResult( doLoad( event, dependentPersister, dependentEntityKey, options ) );
  }
View Full Code Here


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

    // make it circular-reference safe
    final EntityKey entityKey = session.generateEntityKey( id, subclassPersister );
    TwoPhaseLoad.addUninitializedCachedEntity(
        entityKey,
        result,
        subclassPersister,
        LockMode.NONE,
View Full Code Here

      // key value upon which to doAfterTransactionCompletion the breaking logic.  However,
      // it is also then called from getRowFromResultSet() which is certainly
      // not the most efficient.  But the call here is needed, and there
      // currently is no other way without refactoring of the doQuery()/getRowFromResultSet()
      // methods
      final EntityKey currentKey = getKeyFromResultSet(
          0,
          getEntityPersisters()[0],
          null,
          resultSet,
          session
View Full Code Here

      if ( resultSet.isFirst() ) {
        // don't even bother trying to read any further
        return null;
      }

      EntityKey keyToRead = null;
      // This check is needed since processing leaves the cursor
      // after the last physical row for the current logical row;
      // thus if we are after the last physical row, this might be
      // caused by either:
      //      1) scrolling to the last logical row
      //      2) scrolling past the last logical row
      // In the latter scenario, the previous logical row
      // really is the last logical row.
      //
      // In all other cases, we should process back two
      // logical records (the current logic row, plus the
      // previous logical row).
      if ( resultSet.isAfterLast() && isLogicallyAfterLast ) {
        // position cursor to the last row
        resultSet.last();
        keyToRead = getKeyFromResultSet(
            0,
            getEntityPersisters()[0],
            null,
            resultSet,
            session
          );
      }
      else {
        // Since the result set cursor is always left at the first
        // physical row after the "last processed", we need to jump
        // back one position to get the key value we are interested
        // in skipping
        resultSet.previous();

        // sequentially read the result set in reverse until we recognize
        // a change in the key value.  At that point, we are pointed at
        // the last physical sequential row for the logical row in which
        // we are interested in processing
        boolean firstPass = true;
        final EntityKey lastKey = getKeyFromResultSet(
            0,
            getEntityPersisters()[0],
            null,
            resultSet,
            session
          );
        while ( resultSet.previous() ) {
          EntityKey checkKey = getKeyFromResultSet(
              0,
              getEntityPersisters()[0],
              null,
              resultSet,
              session
            );

          if ( firstPass ) {
            firstPass = false;
            keyToRead = checkKey;
          }

          if ( !lastKey.equals( checkKey ) ) {
            break;
          }
        }

      }

      // Read backwards until we read past the first physical sequential
      // row with the key we are interested in loading
      while ( resultSet.previous() ) {
        EntityKey checkKey = getKeyFromResultSet(
            0,
            getEntityPersisters()[0],
            null,
            resultSet,
            session
View Full Code Here

// from the new scrolling stuff.
//
// Would need to change the way the max-row stuff is handled (i.e. behind an interface) so
// that I could do the control breaking at the means to know when to stop

    final EntityKey optionalObjectKey = getOptionalObjectKey( queryParameters, session );
    final LockMode[] lockModesArray = getLockModes( queryParameters.getLockOptions() );
    final boolean createSubselects = isSubselectLoadingEnabled();
    final List subselectResultKeys = createSubselects ? new ArrayList() : null;
    final List results = new ArrayList();
View Full Code Here

      EntityType[] ownerAssociationTypes = getOwnerAssociationTypes();
      for ( int i = 0; i < keys.length; i++ ) {

        int owner = owners[i];
        if ( owner > -1 ) {
          EntityKey ownerKey = keys[owner];
          if ( keys[i] == null && ownerKey != null ) {

            final PersistenceContext persistenceContext = session.getPersistenceContext();

            /*final boolean isPrimaryKey;
View Full Code Here

    final Object[] rowResults = new Object[cols];

    for ( int i = 0; i < cols; i++ ) {

      Object object = null;
      EntityKey key = keys[i];

      if ( keys[i] == null ) {
        //do nothing
      }
      else {
View Full Code Here

   * Get the current state of the entity as known to the underlying
   * database, or null if there is no corresponding row
   */
  public Object[] getDatabaseSnapshot(Serializable id, EntityPersister persister)
  throws HibernateException {
    final EntityKey key = session.generateEntityKey( id, persister );
    Object cached = entitySnapshotsByKey.get(key);
    if (cached!=null) {
      return cached==NO_ROW ? null : (Object[]) cached;
    }
    else {
View Full Code Here

   * @param proxy The proxy to reassociate.
   */
  private void reassociateProxy(LazyInitializer li, HibernateProxy proxy) {
    if ( li.getSession() != this.getSession() ) {
      final EntityPersister persister = session.getFactory().getEntityPersister( li.getEntityName() );
      final EntityKey key = session.generateEntityKey( li.getIdentifier(), persister );
        // any earlier proxy takes precedence
      if ( !proxiesByKey.containsKey( key ) ) {
        proxiesByKey.put( key, proxy );
      }
      proxy.getHibernateLazyInitializer().setSession( session );
View Full Code Here

  public void replaceDelayedEntityIdentityInsertKeys(EntityKey oldKey, Serializable generatedId) {
    Object entity = entitiesByKey.remove( oldKey );
    EntityEntry oldEntry = ( EntityEntry ) entityEntries.remove( entity );
    parentsByChild.clear();

    final EntityKey newKey = session.generateEntityKey( generatedId, oldEntry.getPersister() );
    addEntity( newKey, entity );
    addEntry(
        entity,
            oldEntry.getStatus(),
            oldEntry.getLoadedState(),
View Full Code Here

TOP

Related Classes of org.hibernate.engine.spi.EntityKey

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.