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

0

I'm having this error 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'm not sure how to identify my error ..

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));
    }
}
    
asked by anonymous 14.12.2017 / 19:26

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 annotated 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 create a new class that has these two objects as attributes and use it as an argument.

    
14.12.2017 / 19:38