E - entity typepublic class EntityChangedEvent<E>
extends org.springframework.context.ApplicationEvent
implements org.springframework.core.ResolvableTypeProvider
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();
//...
}
}
| 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> entityId,
EntityChangedEvent.Type type,
AttributeChanges changes,
MetaClass originalMetaClass)
INTERNAL.
|
| Modifier and Type | Method and Description |
|---|---|
AttributeChanges |
getChanges()
Returns an object describing changes in the entity attributes.
|
Id<E> |
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> entityId,
EntityChangedEvent.Type type,
AttributeChanges changes,
MetaClass originalMetaClass)
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.ResolvableTypeProviderpublic java.lang.String toString()
toString in class java.util.EventObject