/** * Is this instance persistent or detached? * <p/> * If <tt>assumed</tt> is non-null, don't hit the database to make the determination, instead assume that * value; the client code must be prepared to "recover" in the case that this assumed result is incorrect. * * @param entityName The name of the entity * @param entity The entity instance * @param assumed The assumed return value, if avoiding database hit is desired * @param session The session * * @return {@code true} if the given entity is not transient (meaning it is either detached/persistent) */ @SuppressWarnings("SimplifiableIfStatement") public static boolean isNotTransient(String entityName, Object entity, Boolean assumed, SharedSessionContractImplementor session) { if ( entity instanceof HibernateProxy ) { return true; } if ( session.getPersistenceContext().isEntryFor( entity ) ) { return true; } // todo : shouldnt assumed be revered here? return !isTransient( entityName, entity, assumed, session ); }
ForeignKeys.isTransient( associatedEntityName, original, Boolean.FALSE, session ) ) {
if ( isTransient( entityName, object, Boolean.FALSE, session ) ) { throw new TransientObjectException( "object references an unsaved transient instance - save the transient instance before flushing: " +
@Override public void noCascade( EventSource session, Object parent, EntityPersister persister, Type propertyType, int propertyIndex) { if ( propertyType.isEntityType() ) { Object child = persister.getPropertyValue( parent, propertyIndex ); String childEntityName = ((EntityType) propertyType).getAssociatedEntityName( session.getFactory() ); if ( child != null && !isInManagedState( child, session ) && !(child instanceof HibernateProxy) //a proxy cannot be transient and it breaks ForeignKeys.isTransient && ForeignKeys.isTransient( childEntityName, child, null, session ) ) { String parentEntityName = persister.getEntityName(); String propertyName = persister.getPropertyNames()[propertyIndex]; throw new TransientPropertyValueException( "object references an unsaved transient instance - save the transient instance before flushing", childEntityName, parentEntityName, propertyName ); } } }
return isTransient( entityName, object, null, session );
if ( ForeignKeys.isTransient( entityName, entity, getAssumedUnsaved(), source ) ) { if ( traceEnabled ) { LOG.tracev( "Transient instance of: {0}", getLoggableName( entityName, entity ) );
if ( ForeignKeys.isTransient( persister.getEntityName(), entity, null, source ) ) { deleteTransientEntity( source, entity, event.isCascadeDeleteEnabled(), persister, transientEntities );
/** * Is this instance persistent or detached? * If <tt>assumed</tt> is non-null, don't hit the database to make the * determination, instead assume that value; the client code must be * prepared to "recover" in the case that this assumed result is incorrect. */ public static boolean isNotTransient(String entityName, Object entity, Boolean assumed, SessionImplementor session) throws HibernateException { if (entity instanceof HibernateProxy) return true; if ( session.getPersistenceContext().isEntryFor(entity) ) return true; return !isTransient(entityName, entity, assumed, session); }
/** * Is this instance persistent or detached? * If <tt>assumed</tt> is non-null, don't hit the database to make the * determination, instead assume that value; the client code must be * prepared to "recover" in the case that this assumed result is incorrect. */ public static boolean isNotTransient(String entityName, Object entity, Boolean assumed, SessionImplementor session) throws HibernateException { if (entity instanceof HibernateProxy) return true; if ( session.getPersistenceContext().isEntryFor(entity) ) return true; return !isTransient(entityName, entity, assumed, session); }
/** * Is this instance persistent or detached? * <p/> * If <tt>assumed</tt> is non-null, don't hit the database to make the determination, instead assume that * value; the client code must be prepared to "recover" in the case that this assumed result is incorrect. * * @param entityName The name of the entity * @param entity The entity instance * @param assumed The assumed return value, if avoiding database hit is desired * @param session The session * * @return {@code true} if the given entity is not transient (meaning it is either detached/persistent) */ @SuppressWarnings("SimplifiableIfStatement") public static boolean isNotTransient(String entityName, Object entity, Boolean assumed, SharedSessionContractImplementor session) { if ( entity instanceof HibernateProxy ) { return true; } if ( session.getPersistenceContext().isEntryFor( entity ) ) { return true; } // todo : shouldnt assumed be revered here? return !isTransient( entityName, entity, assumed, session ); }
if ( isTransient(entityName, object, Boolean.FALSE, session) ) { throw new TransientObjectException( "object references an unsaved transient instance - save the transient instance before flushing: " +
if ( isTransient(entityName, object, Boolean.FALSE, session) ) { throw new TransientObjectException( "object references an unsaved transient instance - save the transient instance before flushing: " +
ForeignKeys.isTransient( associatedEntityName, original, Boolean.FALSE, session ) ) { final Object copy = session.getFactory().getEntityPersister( associatedEntityName ) .instantiate( null, session );
ForeignKeys.isTransient( associatedEntityName, original, Boolean.FALSE, session ) ) { final Object copy = session.getFactory().getEntityPersister( associatedEntityName ) .instantiate( null, session );
if ( isTransient( entityName, object, Boolean.FALSE, session ) ) { throw new TransientObjectException( "object references an unsaved transient instance - save the transient instance before flushing: " +
@Override public void noCascade( EventSource session, Object child, Object parent, EntityPersister persister, int propertyIndex) { if ( child == null ) { return; } Type type = persister.getPropertyTypes()[propertyIndex]; if ( type.isEntityType() ) { String childEntityName = ( ( EntityType ) type ).getAssociatedEntityName( session.getFactory() ); if ( ! isInManagedState( child, session ) && ! ( child instanceof HibernateProxy ) //a proxy cannot be transient and it breaks ForeignKeys.isTransient && ForeignKeys.isTransient( childEntityName, child, null, session ) ) { String parentEntiytName = persister.getEntityName(); String propertyName = persister.getPropertyNames()[propertyIndex]; throw new TransientPropertyValueException( "object references an unsaved transient instance - save the transient instance before flushing", childEntityName, parentEntiytName, propertyName ); } } } @Override
@Override public void noCascade( EventSource session, Object child, Object parent, EntityPersister persister, int propertyIndex) { if ( child == null ) { return; } Type type = persister.getPropertyTypes()[propertyIndex]; if ( type.isEntityType() ) { String childEntityName = ( ( EntityType ) type ).getAssociatedEntityName( session.getFactory() ); if ( ! isInManagedState( child, session ) && ! ( child instanceof HibernateProxy ) //a proxy cannot be transient and it breaks ForeignKeys.isTransient && ForeignKeys.isTransient( childEntityName, child, null, session ) ) { String parentEntiytName = persister.getEntityName(); String propertyName = persister.getPropertyNames()[propertyIndex]; throw new TransientPropertyValueException( "object references an unsaved transient instance - save the transient instance before flushing", childEntityName, parentEntiytName, propertyName ); } } } @Override
return isTransient( entityName, object, null, session );
return isTransient(entityName, object, null, session);
if ( ForeignKeys.isTransient( entityName, entity, getAssumedUnsaved(), source ) ) { if ( traceEnabled ) { LOG.tracev( "Transient instance of: {0}", getLoggableName( entityName, entity ) );