Callback methods annotated in a Listener bean class must Return void and take one argument: javax.persistence.Preupdate

Asked

Viewed 352 times

0

I’m having this mistake on my console...

Caused by: javax.persistence.PersistenceException: Callback methods annotated in a listener bean class must return void and take one argument: javax.persistence.PreUpdate - public void digifred.model.aud.global.LogradourosEntityListener.preUpdate(digifred.model.global.Logradouros,java.util.Date)
    at org.hibernate.jpa.event.internal.jpa.CallbackBuilderLegacyImpl.resolveCallbacks(CallbackBuilderLegacyImpl.java:180) ~[hibernate-entitymanager-5.0.12.Final.jar:5.0.12.Final]
    at org.hibernate.jpa.event.internal.jpa.CallbackBuilderLegacyImpl.buildCallbacksForEntity(CallbackBuilderLegacyImpl.java:69) ~[hibernate-entitymanager-5.0.12.Final.jar:5.0.12.Final] 

I can’t identify my mistake..

public class LogradourosEntityListener {

    @PrePersist
    public void prePersist(Logradouros target, Date modifiedDate) { 
        perform(target,Acoes.INSERTED, modifiedDate);

    }

    @PreUpdate
    public void preUpdate(Logradouros target, Date modifiedDate) { 
         perform(target, Acoes.UPDATED, modifiedDate);

    }

    @PreRemove
    public void preRemove(Logradouros target,Date modifiedDate) { 
        perform(target, Acoes.DELETED, modifiedDate);

    }



    @Transactional()
    private void perform(Logradouros target, Acoes acao, Date modifiedDate) {
        EntityManager entityManager = BeanUtil.getBean(EntityManager.class);
        entityManager.persist(new LogradourosHistorico(target, acao, modifiedDate));
    }
}

1 answer

2


Caused by: javax.persistence.PersistenceException: Callback methods annotated in a listener bean class must return void and take one argument

That’s what the message says. Your methods noted with @PrePersist, @PreUpdate and @PreRemove can only have one argument. In all your methods you have put two: Logradouros target and Date modifiedDate.

Either you remove one of them, or you create a new class that has these two objects as attributes and use it as an argument.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.