E
- entity typeK
- entity identifier typepublic class EntityChangedEvent<E extends Entity<K>,K>
extends org.springframework.context.ApplicationEvent
implements org.springframework.core.ResolvableTypeProvider
The event is sent by the framework if the entity has @PublishEntityChangedEvents
annotation.
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, UUID> event) { AttributeChanges changes = event.getChanges(); //... } }
Modifier and Type | Class and Description |
---|---|
static class |
EntityChangedEvent.Type
Type of the event:
EntityChangedEvent.Type.CREATED , EntityChangedEvent.Type.UPDATED or EntityChangedEvent.Type.DELETED . |
Constructor and Description |
---|
EntityChangedEvent(java.lang.Object source,
Id<E,K> entityId,
EntityChangedEvent.Type type,
AttributeChanges changes)
INTERNAL.
|
Modifier and Type | Method and Description |
---|---|
AttributeChanges |
getChanges()
Returns an object describing changes in the entity attributes.
|
Id<E,K> |
getEntityId()
Returns the entity id.
|
org.springframework.core.ResolvableType |
getResolvableType()
INTERNAL.
|
EntityChangedEvent.Type |
getType()
Returns the event type.
|
java.lang.String |
toString() |
public EntityChangedEvent(java.lang.Object source, Id<E,K> entityId, EntityChangedEvent.Type type, AttributeChanges changes)
public EntityChangedEvent.Type getType()
public AttributeChanges getChanges()
CREATED
event, contains attributes stored with non-null values. Old values are null.
UPDATED
event, contains changed attributes. Old values are the attribute values at the moment
of loading the entity from the database.
DELETED
event, contains all entity attributes. Old values are the attribute values at the moment
of loading the entity from the database.
public org.springframework.core.ResolvableType getResolvableType()
getResolvableType
in interface org.springframework.core.ResolvableTypeProvider
public java.lang.String toString()
toString
in class java.util.EventObject