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
Modifier and TypeClassDescriptionstatic enum
Type of the event:EntityChangedEvent.Type.CREATED
,EntityChangedEvent.Type.UPDATED
orEntityChangedEvent.Type.DELETED
. -
Field Summary
Fields inherited from class java.util.EventObject
source
-
Constructor Summary
ConstructorDescriptionEntityChangedEvent
(Object source, Id<E> entityId, EntityChangedEvent.Type type, AttributeChanges changes, MetaClass originalMetaClass) INTERNAL. -
Method Summary
Methods inherited from class org.springframework.context.ApplicationEvent
getTimestamp
Methods 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
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.
- For
-
getResolvableType
public org.springframework.core.ResolvableType getResolvableType()INTERNAL.- Specified by:
getResolvableType
in interfaceorg.springframework.core.ResolvableTypeProvider
-
toString
- Overrides:
toString
in classEventObject
-