Top Description Inners Constructors Methods
org.hibernate.engine

public final Class ForeignKeys

extends Object
Class Inheritance
Imports
java.io.Serializable, org.hibernate.HibernateException, .TransientObjectException, org.hibernate.intercept.LazyPropertyInitializer, org.hibernate.persister.entity.EntityPersister, org.hibernate.proxy.HibernateProxy, .LazyInitializer, org.hibernate.type.CompositeType, .EntityType, .Type

Algorithms related to foreign key constraint transparency
Author
Gavin King

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static Serializable
getEntityIdentifierIfNotUnsaved(final String entityName, final Object object, final SessionImplementor session)

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.

public static boolean
isNotTransient(String entityName, Object entity, Boolean assumed, SessionImplementor session)

Is this instance persistent or detached?

public static boolean
isTransient(String entityName, Object entity, Boolean assumed, SessionImplementor session)

Is this instance, which we know is not persistent, actually transient?

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

ForeignKeysback to summary
private ForeignKeys()

Method Detail

getEntityIdentifierIfNotUnsavedback to summary
public static Serializable getEntityIdentifierIfNotUnsaved(final String entityName, final Object object, final SessionImplementor session) throws HibernateException

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).

isNotTransientback to summary
public static boolean isNotTransient(String entityName, Object entity, Boolean assumed, SessionImplementor session) throws HibernateException

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.

isTransientback to summary
public static boolean isTransient(String entityName, Object entity, Boolean assumed, SessionImplementor session) throws HibernateException

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.

org.hibernate.engine back to summary

public Class ForeignKeys.Nullifier

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final boolean
private final boolean
private final Object
private final SessionImplementor

Constructor Summary

AccessConstructor and Description
public
Nullifier(Object self, boolean isDelete, boolean isEarlyInsert, SessionImplementor session)

Method Summary

Modifier and TypeMethod and Description
private boolean
isNullifiable(final String entityName, Object object)

Determine if the object already exists in the database, using a "best guess"

public void
nullifyTransientReferences(final Object[] values, final Type[] types)

Nullify all references to entities that have not yet been inserted in the database, where the foreign key points toward that entity

private Object
nullifyTransientReferences(final Object value, final Type type)

Return null if the argument is an "unsaved" entity (ie.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

isDeleteback to summary
private final boolean isDelete
isEarlyInsertback to summary
private final boolean isEarlyInsert
selfback to summary
private final Object self
sessionback to summary
private final SessionImplementor session

Constructor Detail

Nullifierback to summary
public Nullifier(Object self, boolean isDelete, boolean isEarlyInsert, SessionImplementor session)

Method Detail

isNullifiableback to summary
private boolean isNullifiable(final String entityName, Object object) throws HibernateException

Determine if the object already exists in the database, using a "best guess"

nullifyTransientReferencesback to summary
public void nullifyTransientReferences(final Object[] values, final Type[] types) throws HibernateException

Nullify all references to entities that have not yet been inserted in the database, where the foreign key points toward that entity

nullifyTransientReferencesback to summary
private Object nullifyTransientReferences(final Object value, final Type type) throws HibernateException

Return null if the argument is an "unsaved" entity (ie. one with no existing database row), or the input argument otherwise. This is how Hibernate avoids foreign key constraint violations.