Class SqlServerForeignKeyLockingEvent
java.lang.Object
io.hypersistence.optimizer.core.event.AbstractEvent
io.hypersistence.optimizer.hibernate.event.mapping.EntityMappingEvent
io.hypersistence.optimizer.hibernate.event.mapping.association.SqlServerForeignKeyLockingEvent
- All Implemented Interfaces:
Event,Serializable
The
SqlServerForeignKeyLockingEvent indicates that an entity contains
ManyToOne associations or
non-shared OneToOne associations, without the entity being
configured to use DynamicUpdate.
By default, Hibernate includes all non-id entity columns in the SET clause of an UPDATE statement,
and, for this reason, on SQL Server, a shared lock is acquired on the parent table record
to ensure that the Foreign Key is not going to reference a non-existing parent row.
So, to reduce the likelihood of locking and deadlocks, you are better off setting
DynamicUpdate on such entities.- Since:
- 2.4.0
- Author:
- Vlad Mihalcea
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.hypersistence.optimizer.core.event.Event
Event.Priority -
Constructor Summary
ConstructorsConstructorDescriptionSqlServerForeignKeyLockingEvent(EntityMetadata entityMetadata, int manyToOneAssociationCount, int oneToOneAssociationCount) Instantiate the event using the provided parameters. -
Method Summary
Modifier and TypeMethodDescriptionintGet the number of many-to-one associations that can be affected by the Foreign Key locking issue.intGet the number of one-to-one associations that can be affected by the Foreign Key locking issue.Get theEvent.Priorityof thisEventMethods inherited from class io.hypersistence.optimizer.hibernate.event.mapping.EntityMappingEvent
getEntityClass, getEntityNameMethods inherited from class io.hypersistence.optimizer.core.event.AbstractEvent
getInfoUrl
-
Constructor Details
-
SqlServerForeignKeyLockingEvent
public SqlServerForeignKeyLockingEvent(EntityMetadata entityMetadata, int manyToOneAssociationCount, int oneToOneAssociationCount) Instantiate the event using the provided parameters.- Parameters:
entityMetadata- entity metadatamanyToOneAssociationCount- many-to-one associations that can be affected by the Foreign Key locking issueoneToOneAssociationCount- one-to-one associations that can be affected by the Foreign Key locking issue
-
-
Method Details
-
getManyToOneAssociationCount
public int getManyToOneAssociationCount()Get the number of many-to-one associations that can be affected by the Foreign Key locking issue.- Returns:
- the number many-to-one associations that can be affected by the Foreign Key locking issue
-
getOneToOneAssociationCount
public int getOneToOneAssociationCount()Get the number of one-to-one associations that can be affected by the Foreign Key locking issue.- Returns:
- the number one-to-one associations that can be affected by the Foreign Key locking issue
-
getPriority
Get theEvent.Priorityof thisEvent- Returns:
- the
Event.Priorityof thisEvent
-
getDescription
-