Package io.jmix.core.event
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:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumType of the event:EntityChangedEvent.Type.CREATED,EntityChangedEvent.Type.UPDATEDorEntityChangedEvent.Type.DELETED. -
Field Summary
Fields inherited from class java.util.EventObject
source -
Constructor Summary
ConstructorsConstructorDescriptionEntityChangedEvent(Object source, Id<E> entityId, EntityChangedEvent.Type type, AttributeChanges changes, MetaClass originalMetaClass) INTERNAL. -
Method Summary
Methods inherited from class org.springframework.context.ApplicationEvent
getTimestampMethods inherited from class java.util.EventObject
getSource
-
Constructor Details
-
EntityChangedEvent
public EntityChangedEvent(Object source, Id<E> entityId, EntityChangedEvent.Type type, AttributeChanges changes, MetaClass originalMetaClass) INTERNAL.
-
-
Method Details
-
getEntityId
Returns the entity id. -
getType
Returns the event type. -
getChanges
Returns an object describing changes in the entity attributes.- For
CREATEDevent, contains attributes stored with non-null values. Old values are null. - For
UPDATEDevent, contains changed attributes. Old values are the attribute values at the moment of loading the entity from the database. - For
DELETEDevent, contains all entity attributes. Old values are the attribute values at the moment of loading the entity from the database.
- For
-
getResolvableType
public org.springframework.core.ResolvableType getResolvableType()INTERNAL.- Specified by:
getResolvableTypein interfaceorg.springframework.core.ResolvableTypeProvider
-
toString
- Overrides:
toStringin classEventObject
-