Package org.hibernate

Examples of org.hibernate.TransientObjectException


        return LockMode.NONE;
      }
    }
    EntityEntry e = persistenceContext.getEntry(object);
    if ( e == null ) {
      throw new TransientObjectException( "Given object not associated with the session" );
    }
    if ( e.getStatus() != Status.MANAGED ) {
      throw new ObjectDeletedException(
          "The given object was deleted",
          e.getId(),
View Full Code Here


    errorIfClosed();
    checkTransactionSynchStatus();
    if ( object instanceof HibernateProxy ) {
      LazyInitializer li = ( (HibernateProxy) object ).getHibernateLazyInitializer();
      if ( li.getSession() != this ) {
        throw new TransientObjectException( "The proxy was not associated with this session" );
      }
      return li.getIdentifier();
    }
    else {
      EntityEntry entry = persistenceContext.getEntry(object);
      if ( entry == null ) {
        throw new TransientObjectException( "The instance was not associated with this session" );
      }
      return entry.getId();
    }
  }
View Full Code Here

  public String getEntityName(Object object) {
    errorIfClosed();
    checkTransactionSynchStatus();
    if (object instanceof HibernateProxy) {
      if ( !persistenceContext.containsProxy( object ) ) {
        throw new TransientObjectException("proxy was not associated with the session");
      }
      object = ( (HibernateProxy) object ).getHibernateLazyInitializer().getImplementation();
    }

    EntityEntry entry = persistenceContext.getEntry(object);
View Full Code Here

    }
    return entry.getPersister().getEntityName();
  }

  private void throwTransientObjectException(Object object) throws HibernateException {
    throw new TransientObjectException(
        "object references an unsaved transient instance - save the transient instance before flushing: " +
        guessEntityName(object)
      );
  }
View Full Code Here

      isReadOnly = ( ( HibernateProxy ) entityOrProxy ).getHibernateLazyInitializer().isReadOnly();
    }
    else {
      EntityEntry ee =  getEntry( entityOrProxy );
      if ( ee == null ) {
        throw new TransientObjectException("Instance was not associated with this persistence context" );
      }
      isReadOnly = ee.isReadOnly();
    }
    return isReadOnly;
  }
View Full Code Here

  }

  private void setEntityReadOnly(Object entity, boolean readOnly) {
    EntityEntry entry = getEntry(entity);
    if (entry == null) {
      throw new TransientObjectException("Instance was not associated with this persistence context" );
    }
    entry.setReadOnly(readOnly, entity );
    hasNonReadOnlyEntities = hasNonReadOnlyEntities || ! readOnly;
  }
View Full Code Here

          transientEntityNames.add( transientEntityName );
          log.trace( "transient instance could not be processed by merge when checking nullability: " +
              transientEntityName + "[" + transientEntity + "]" );
        }
        if ( isNullabilityCheckedGlobal( event.getSession() ) ) {
          throw new TransientObjectException(
            "one or more objects is an unsaved transient instance - save transient instance(s) before merging: " +
            transientEntityNames );
        }
        else {
          log.trace( "retry saving transient instances without checking nullability" );
View Full Code Here

        // this entity should not be put in transientCopyCache, because it was
        // not included in the merge;
        // if the global setting for checking nullability is false, the non-nullable
        // reference to this entity will be detected later
        if ( isNullabilityCheckedGlobal( event.getSession() ) ) {
          throw new TransientObjectException(
            "object is an unsaved transient instance - save the transient instance before merging: " +
              event.getSession().guessEntityName( copy )
          );
        }
      }
View Full Code Here

      if ( id == null ) {
        // context-entity-identifier returns null explicitly if the entity
        // is not associated with the persistence context; so make some
        // deeper checks...
        if ( isTransient(entityName, object, Boolean.FALSE, session) ) {
          throw new TransientObjectException(
              "object references an unsaved transient instance - save the transient instance before flushing: " +
              (entityName == null ? session.guessEntityName( object ) : entityName)
          );
        }
        id = session.getEntityPersister( entityName, object ).getIdentifier( object, session );
View Full Code Here

        return LockMode.NONE;
      }
    }
    EntityEntry e = persistenceContext.getEntry(object);
    if ( e == null ) {
      throw new TransientObjectException( "Given object not associated with the session" );
    }
    if ( e.getStatus() != Status.MANAGED ) {
      throw new ObjectDeletedException(
          "The given object was deleted",
          e.getId(),
View Full Code Here

TOP

Related Classes of org.hibernate.TransientObjectException

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.