Home  >  Forum  >  Hibernate
Post New Query

Callback methods annotated in a listener bean class must return void


joined on
August 12,2015
Asked on February 11,2016
Caused by: javax.persistence.PersistenceException: Callback methods annotated in a listener bean class must return void and take one argument: javax.persistence.PrePersist - 
at org.hibernate.jpa.event.internal.jpa.LegacyCallbackProcessor.resolveCallbacks(LegacyCallbackProcessor.java:168)
at org.hibernate.jpa.event.internal.jpa.LegacyCallbackProcessor.processCallbacksForEntity(LegacyCallbackProcessor.java:66)
at org.hibernate.jpa.event.spi.JpaIntegrator.integrate(JpaIntegrator.java:140)
at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:278)
at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:444)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:879)

What am I missing?
joined on
November 18,2013
Replied on February 11,2016

Callnback method must return void type and accept one argument as follows.

public class UserListener {
	@PrePersist
	public void userPrePersist(User ob) {
		System.out.println("Listening User Pre Persist : " + ob.getName());
	}
}

Find the link

http://www.concretepage.com/java/jpa/jpa-entitylisteners-example-with-callbacks-prepersist-postpersist-postload-preupdate-postupdate-preremove-postremove

Write Answer








Copyright ©2017 concretepage.com, all rights reserved |Privacy Policy | Contact Us