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

public class SqlServerForeignKeyLockingEvent extends EntityMappingEvent
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:
  • Constructor Details

    • SqlServerForeignKeyLockingEvent

      public SqlServerForeignKeyLockingEvent(EntityMetadata entityMetadata, int manyToOneAssociationCount, int oneToOneAssociationCount)
      Instantiate the event using the provided parameters.
      Parameters:
      entityMetadata - entity metadata
      manyToOneAssociationCount - many-to-one associations that can be affected by the Foreign Key locking issue
      oneToOneAssociationCount - 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

      public Event.Priority getPriority()
      Get the Event.Priority of this Event
      Returns:
      the Event.Priority of this Event
    • getDescription

      public String getDescription()
      Get the String description of this Event
      Returns:
      the String description of this Event