Examples of PersistenceContext


Examples of org.hibernate.engine.PersistenceContext

        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;
            final boolean isSpecialOneToOne;
            if ( ownerAssociationTypes == null || ownerAssociationTypes[i] == null ) {
              isPrimaryKey = true;
              isSpecialOneToOne = false;
            }
            else {
              isPrimaryKey = ownerAssociationTypes[i].getRHSUniqueKeyPropertyName()==null;
              isSpecialOneToOne = ownerAssociationTypes[i].getLHSPropertyName()!=null;
            }*/
           
            //TODO: can we *always* use the "null property" approach for everything?
            /*if ( isPrimaryKey && !isSpecialOneToOne ) {
              persistenceContext.addNonExistantEntityKey(
                  new EntityKey( ownerKey.getIdentifier(), persisters[i], session.getEntityMode() )
              );
            }
            else if ( isSpecialOneToOne ) {*/
            boolean isOneToOneAssociation = ownerAssociationTypes!=null &&
                ownerAssociationTypes[i]!=null &&
                ownerAssociationTypes[i].isOneToOne();
            if ( isOneToOneAssociation ) {
              persistenceContext.addNullProperty( ownerKey,
                  ownerAssociationTypes[i].getPropertyName() );
            }
            /*}
            else {
              persistenceContext.addNonExistantEntityUniqueKey( new EntityUniqueKey(
View Full Code Here

Examples of org.hibernate.engine.PersistenceContext

          final CollectionAliases descriptor,
          final ResultSet rs,
          final SessionImplementor session)
  throws HibernateException, SQLException {

    final PersistenceContext persistenceContext = session.getPersistenceContext();

    final Serializable collectionRowKey = (Serializable) persister.readKey(
        rs,
        descriptor.getSuffixedKeyAliases(),
        session
      );
   
    if ( collectionRowKey != null ) {
      // we found a collection element in the result set

      if ( log.isDebugEnabled() ) {
        log.debug(
            "found row of collection: " +
            MessageHelper.collectionInfoString( persister, collectionRowKey, getFactory() )
          );
      }

      Object owner = optionalOwner;
      if ( owner == null ) {
        owner = persistenceContext.getCollectionOwner( collectionRowKey, persister );
        if ( owner == null ) {
          //TODO: This is assertion is disabled because there is a bug that means the
          //    original owner of a transient, uninitialized collection is not known
          //    if the collection is re-referenced by a different object associated
          //    with the current Session
          //throw new AssertionFailure("bug loading unowned collection");
        }
      }

      PersistentCollection rowCollection = persistenceContext.getLoadContexts()
          .getCollectionLoadContext( rs )
          .getLoadingCollection( persister, collectionRowKey );

      if ( rowCollection != null ) {
        rowCollection.readFrom( rs, persister, descriptor, owner );
      }

    }
    else if ( optionalKey != null ) {
      // we did not find a collection element in the result set, so we
      // ensure that a collection is created with the owner's identifier,
      // since what we have is an empty collection

      if ( log.isDebugEnabled() ) {
        log.debug(
            "result set contains (possibly empty) collection: " +
            MessageHelper.collectionInfoString( persister, optionalKey, getFactory() )
          );
      }

      persistenceContext.getLoadContexts()
          .getCollectionLoadContext( rs )
          .getLoadingCollection( persister, optionalKey ); // handle empty collection

    }
View Full Code Here

Examples of org.hibernate.engine.PersistenceContext

        getIdentifierOrUniqueKeyType( factory ),
        session.getEntityMode(),
        session.getFactory()
    );

    final PersistenceContext persistenceContext = session.getPersistenceContext();
    Object result = persistenceContext.getEntity( euk );
    if ( result == null ) {
      result = persister.loadByUniqueKey( uniqueKeyPropertyName, key, session );
    }
    return result == null ? null : persistenceContext.proxyFor( result );
  }
View Full Code Here

Examples of org.hibernate.engine.PersistenceContext

    if ( !isSubselectLoadable() ) {
      return null;
    }
   
    final PersistenceContext persistenceContext = session.getPersistenceContext();
   
    SubselectFetch subselect = persistenceContext.getBatchFetchQueue()
      .getSubselect( new EntityKey( key, getOwnerEntityPersister(), session.getEntityMode() ) );
   
    if (subselect == null) {
      return null;
    }
    else {
     
      // Take care of any entities that might have
      // been evicted! 
      Iterator iter = subselect.getResult().iterator();
      while ( iter.hasNext() ) {
        if ( !persistenceContext.containsEntity( (EntityKey) iter.next() ) ) {
          iter.remove();
        }
      } 
     
      // Run a subquery loader
View Full Code Here

Examples of org.hibernate.engine.spi.PersistenceContext

      OgmLoadingContext ogmLoadingContext,
      boolean returnProxies) {


    //TODO handles the read only
    final PersistenceContext persistenceContext = session.getPersistenceContext();
    boolean defaultReadOnlyOrig = persistenceContext.isDefaultReadOnly();
    persistenceContext.beforeLoad();
    List<Object> result;
    try {
      try {
        result = doQuery(
            session,
            qp,
            ogmLoadingContext,
            returnProxies
        );
      }
      finally {
        persistenceContext.afterLoad();
      }
      persistenceContext.initializeNonLazyCollections();
    }
    finally {
      // Restore the original default
      persistenceContext.setDefaultReadOnly( defaultReadOnlyOrig );
    }

    log.debug( "done entity load" );
    return result;
  }
View Full Code Here

Examples of org.hibernate.engine.spi.PersistenceContext

    final CollectionAliases descriptor,
    final ResultSet rs,
    final SessionImplementor session)
        throws HibernateException, SQLException {

    final PersistenceContext persistenceContext = session.getPersistenceContext();

    //implement persister.readKey using the grid type (later)
    final Serializable collectionRowKey = (Serializable) persister.readKey(
        rs,
        descriptor.getSuffixedKeyAliases(),
        session
      );

    if ( collectionRowKey != null ) {
      // we found a collection element in the result set

      if ( log.isDebugEnabled() ) {
        log.debug(
            "found row of collection: " +
            MessageHelper.collectionInfoString( persister, collectionRowKey, getFactory() )
          );
      }

      Object owner = optionalOwner;
      if ( owner == null ) {
        owner = persistenceContext.getCollectionOwner( collectionRowKey, persister );
        if ( owner == null ) {
          //TODO: This is assertion is disabled because there is a bug that means the
          //    original owner of a transient, uninitialized collection is not known
          //    if the collection is re-referenced by a different object associated
          //    with the current Session
          //throw new AssertionFailure("bug loading unowned collection");
        }
      }

      PersistentCollection rowCollection = persistenceContext.getLoadContexts()
          .getCollectionLoadContext( rs )
          .getLoadingCollection( persister, collectionRowKey );

      if ( rowCollection != null ) {
        rowCollection.readFrom(
            rs,
            persister,
            descriptor,
            owner );
      }

    }
    else if ( optionalKey != null ) {
      // we did not find a collection element in the result set, so we
      // ensure that a collection is created with the owner's identifier,
      // since what we have is an empty collection

      if ( log.isDebugEnabled() ) {
        log.debug(
            "result set contains (possibly empty) collection: " +
            MessageHelper.collectionInfoString( persister, optionalKey, getFactory() )
          );
      }

      persistenceContext.getLoadContexts()
          .getCollectionLoadContext( rs )
          .getLoadingCollection( persister, optionalKey ); // handle empty collection

    }
View Full Code Here

Examples of org.hibernate.engine.spi.PersistenceContext

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

            final PersistenceContext persistenceContext = session.getPersistenceContext();

            /*final boolean isPrimaryKey;
            final boolean isSpecialOneToOne;
            if ( ownerAssociationTypes == null || ownerAssociationTypes[i] == null ) {
              isPrimaryKey = true;
              isSpecialOneToOne = false;
            }
            else {
              isPrimaryKey = ownerAssociationTypes[i].getRHSUniqueKeyPropertyName()==null;
              isSpecialOneToOne = ownerAssociationTypes[i].getLHSPropertyName()!=null;
            }*/

            //TODO: can we *always* use the "null property" approach for everything?
            /*if ( isPrimaryKey && !isSpecialOneToOne ) {
              persistenceContext.addNonExistantEntityKey(
                  new EntityKey( ownerKey.getIdentifier(), persisters[i], session.getEntityMode() )
              );
            }
            else if ( isSpecialOneToOne ) {*/
            boolean isOneToOneAssociation = ownerAssociationTypes != null &&
                ownerAssociationTypes[i] != null &&
                ownerAssociationTypes[i].isOneToOne();
            if ( isOneToOneAssociation ) {
              persistenceContext.addNullProperty( ownerKey,
                  ownerAssociationTypes[i].getPropertyName() );
            }
            /*}
            else {
              persistenceContext.addNonExistantEntityUniqueKey( new EntityUniqueKey(
View Full Code Here

Examples of org.openbp.server.persistence.PersistenceContext

      if (processor.getSourceMgrType().equalsIgnoreCase(processor.getTargetMgrType()))
      {
        printError("Source and target model manager classes may not be identical.");
      }

      PersistenceContext pc = processor.getProcessServer().getEngine().getPersistenceContextProvider().obtainPersistenceContext();
      TransactionGuard tg = new TransactionGuard(pc);
      try
      {
        processor.perform();
      }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.