Class ForeignKeys


  • public final class ForeignKeys
    extends java.lang.Object
    Algorithms related to foreign key constraint transparency
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  ForeignKeys.Nullifier
      Delegate for handling nullifying ("null"ing-out) non-cascaded associations
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.util.concurrent.CompletionStage<org.hibernate.engine.internal.NonNullableTransientDependencies> findNonNullableTransientEntities​(java.lang.String entityName, java.lang.Object entity, java.lang.Object[] values, boolean isEarlyInsert, org.hibernate.engine.spi.SharedSessionContractImplementor session)  
      static java.util.concurrent.CompletionStage<java.lang.Object> getEntityIdentifierIfNotUnsaved​(java.lang.String entityName, java.lang.Object object, org.hibernate.engine.spi.SessionImplementor session)
      Return the identifier of the persistent or transient object, or throw an exception if the instance is "unsaved"
      static java.util.concurrent.CompletionStage<java.lang.Boolean> isNotTransient​(java.lang.String entityName, java.lang.Object entity, java.lang.Boolean assumed, org.hibernate.engine.spi.SessionImplementor session)
      Is this instance persistent or detached?
      static java.util.concurrent.CompletionStage<java.lang.Boolean> isTransient​(java.lang.String entityName, java.lang.Object entity, java.lang.Boolean assumed, org.hibernate.engine.spi.SessionImplementor session)
      Is this instance, which we know is not persistent, actually transient?
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • isNotTransient

        public static java.util.concurrent.CompletionStage<java.lang.Boolean> isNotTransient​(java.lang.String entityName,
                                                                                             java.lang.Object entity,
                                                                                             java.lang.Boolean assumed,
                                                                                             org.hibernate.engine.spi.SessionImplementor session)
        Is this instance persistent or detached?

        If assumed 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.

        Parameters:
        entityName - The name of the entity
        entity - The entity instance
        assumed - The assumed return value, if avoiding database hit is desired
        session - The session
        Returns:
        true if the given entity is not transient (meaning it is either detached/persistent)
      • isTransient

        public static java.util.concurrent.CompletionStage<java.lang.Boolean> isTransient​(java.lang.String entityName,
                                                                                          java.lang.Object entity,
                                                                                          java.lang.Boolean assumed,
                                                                                          org.hibernate.engine.spi.SessionImplementor session)
        Is this instance, which we know is not persistent, actually transient?

        If assumed 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.

        Parameters:
        entityName - The name of the entity
        entity - The entity instance
        assumed - The assumed return value, if avoiding database hit is desired
        session - The session
        Returns:
        true if the given entity is transient (unsaved)
      • getEntityIdentifierIfNotUnsaved

        public static java.util.concurrent.CompletionStage<java.lang.Object> getEntityIdentifierIfNotUnsaved​(java.lang.String entityName,
                                                                                                             java.lang.Object object,
                                                                                                             org.hibernate.engine.spi.SessionImplementor session)
                                                                                                      throws org.hibernate.TransientObjectException
        Return the identifier of the persistent or transient object, or throw an exception if the instance is "unsaved"

        Used by OneToOneType and ManyToOneType to determine what id value should be used for an object that may or may not be associated with the session. This does a "best guess" using any/all info available to use (not just the EntityEntry).

        Parameters:
        entityName - The name of the entity
        object - The entity instance
        session - The session
        Returns:
        The identifier
        Throws:
        org.hibernate.TransientObjectException - if the entity is transient (does not yet have an identifier)
      • findNonNullableTransientEntities

        public static java.util.concurrent.CompletionStage<org.hibernate.engine.internal.NonNullableTransientDependencies> findNonNullableTransientEntities​(java.lang.String entityName,
                                                                                                                                                            java.lang.Object entity,
                                                                                                                                                            java.lang.Object[] values,
                                                                                                                                                            boolean isEarlyInsert,
                                                                                                                                                            org.hibernate.engine.spi.SharedSessionContractImplementor session)