Class EntityChangedEvent<E>

java.lang.Object
java.util.EventObject
org.springframework.context.ApplicationEvent
io.jmix.core.event.EntityChangedEvent<E>
Type Parameters:
E - entity type
All Implemented Interfaces:
Serializable, org.springframework.core.ResolvableTypeProvider

public class EntityChangedEvent<E> extends org.springframework.context.ApplicationEvent implements org.springframework.core.ResolvableTypeProvider
A Spring application event that is sent right after an entity is changed in the data store.

You can use @EventListener and @TransactionalEventListener annotations to handle this event. In the former case, the handler will work inside the transaction which changed the entity, in the latter - after commit. The @TransactionalEventListener annotation contains phase attribute which allows you to handle the event before or after transaction commit. Example of event handler:

 @Component("test_OrderLineChangedListener")
 public class OrderLineChangedListener {

     @EventListener
     protected void orderLineChanged(EntityChangedEvent<OrderLine> event) {
         AttributeChanges changes = event.getChanges();
         //...
     }
 }
 
See Also:
  • Constructor Details

  • Method Details

    • getEntityId

      public Id<E> getEntityId()
      Returns the entity id.
    • getType

      public EntityChangedEvent.Type getType()
      Returns the event type.
    • getChanges

      public AttributeChanges getChanges()
      Returns an object describing changes in the entity attributes.
      • For CREATED event, contains attributes stored with non-null values. Old values are null.
      • For UPDATED event, contains changed attributes. Old values are the attribute values at the moment of loading the entity from the database.
      • For DELETED event, contains all entity attributes. Old values are the attribute values at the moment of loading the entity from the database.
    • getResolvableType

      public org.springframework.core.ResolvableType getResolvableType()
      INTERNAL.
      Specified by:
      getResolvableType in interface org.springframework.core.ResolvableTypeProvider
    • toString

      public String toString()
      Overrides:
      toString in class EventObject