EntityChangedEvent is not triggered

Hi,
I’m trying to listen event when an entity is saved to the DB (oracle db in my case).
To implement it:

  1. Add annotation @PublishEntityChangedEvents to an entity

@NamePattern("%s|name")
@Table(name = “SERVER”)
@Entity(name = “fixicch2_Server”)
@PublishEntityChangedEvents
public class Server extends BaseIntIdentityIdEntity {
private static final long serialVersionUID = -3720438496376838041L;
@Id
@SequenceGenerator(name = “SERVER_ID_SEQ”, sequenceName = “SERVER_ID_SEQ”, allocationSize = 1)
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = “SERVER_ID_SEQ”)
@Column(name = “ID”, nullable = false)
private Integer id;

  1. Create Listener

@Component(“fixicch2_ServerChangedListener”)
public class ServerChangedListener {
@Inject
private TransactionalDataManager txDm;
@EventListener
public void beforeCommit(EntityChangedEvent<Server, IdProxy> event) {
EntityChangedEvent.Type changeType = event.getType();

And it doesn’t work. Listener can’t handle event, no errors. Could you please help with it?

Hi @uladzislau_chabatkou,

where did you implement the Listener? Listener for EntityChangedEvent musst be in the core module.

Also try to use the @TransactionalEventListener(phase = TransactionPhase.AFTER_COMMIT) instead of the EntityListener. More about this in EntityChangedEvent - CUBA Platform. Developer’s Manual and https://www.cuba-platform.com/guides/decouple-business-logic-with-app-events#entity_changes_through_entitychangedevent

Greetings
Andreas

Hi @Andreas.Brueck,
The Listener is in core module (I created it via CUBA/Middleware/Beans/New/Event listener)
I’ve tried TransactionalEventListener and EntityListener. The same result. I’ve already seen all related docs and topics, but don’t find the answer.

Can it be linked with oracle db? Also my entity extends BaseIntIdentityIdEntity and has sequence generator. Is it cause?

The problem is in BaseIntIdentityIdEntity and sequence (generated ID).
When my entity extends StandardEntity or BaseUuidEntity then the change event listener works fine.

But the question is still open: why doesn’t the listener work with BaseIntIdentityIdEntity and sequence?

Hi,
Thank you for reporting the problem. We have created a GitHub issue