Package org.hibernate.engine.internal
Class ForeignKeys
- java.lang.Object
-
- org.hibernate.engine.internal.ForeignKeys
-
public final class ForeignKeys extends Object
Algorithms related to foreign key constraint transparency
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classForeignKeys.NullifierDelegate for handling nullifying ("null"ing-out) non-cascaded associations
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static NonNullableTransientDependenciesfindNonNullableTransientEntities(String entityName, Object entity, Object[] values, boolean isEarlyInsert, SharedSessionContractImplementor session)Find all non-nullable references to entities that have not yet been inserted in the database, where the foreign key is a reference to an unsaved transient entity.static ObjectgetEntityIdentifierIfNotUnsaved(String entityName, Object object, SharedSessionContractImplementor session)Return the identifier of the persistent or transient object, or throw an exception if the instance is "unsaved"static booleanisNotTransient(String entityName, Object entity, Boolean assumed, SharedSessionContractImplementor session)Is this instance persistent or detached?static booleanisTransient(String entityName, Object entity, Boolean assumed, SharedSessionContractImplementor session)Is this instance, which we know is not persistent, actually transient?
-
-
-
Method Detail
-
isNotTransient
public static boolean isNotTransient(String entityName, Object entity, Boolean assumed, SharedSessionContractImplementor session)
Is this instance persistent or detached?If
assumedis 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 entityentity- The entity instanceassumed- The assumed return value, if avoiding database hit is desiredsession- The session- Returns:
trueif the given entity is not transient (meaning it is either detached/persistent)
-
isTransient
public static boolean isTransient(String entityName, Object entity, Boolean assumed, SharedSessionContractImplementor session)
Is this instance, which we know is not persistent, actually transient?If
assumedis 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 entityentity- The entity instanceassumed- The assumed return value, if avoiding database hit is desiredsession- The session- Returns:
trueif the given entity is transient (unsaved)
-
getEntityIdentifierIfNotUnsaved
public static Object getEntityIdentifierIfNotUnsaved(String entityName, Object object, SharedSessionContractImplementor session) throws 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 entityobject- The entity instancesession- The session- Returns:
- The identifier
- Throws:
TransientObjectException- if the entity is transient (does not yet have an identifier)
-
findNonNullableTransientEntities
public static NonNullableTransientDependencies findNonNullableTransientEntities(String entityName, Object entity, Object[] values, boolean isEarlyInsert, SharedSessionContractImplementor session)
Find all non-nullable references to entities that have not yet been inserted in the database, where the foreign key is a reference to an unsaved transient entity. .- Parameters:
entityName- - the entity nameentity- - the entity instancevalues- - insertable properties of the object (including backrefs), possibly with substitutionsisEarlyInsert- - true if the entity needs to be executed as soon as possible (e.g., to generate an ID)session- - the session- Returns:
- the transient unsaved entity dependencies that are non-nullable, or null if there are none.
-
-