The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

CatchSandeepVaid (23) [Avatar] Offline
#1
"A class is permitted to override an inherited callback method of the same callback type, and in this case, the overridden method is NOT invoked."
However in the example given, the overriden method is invoked...
@Entity
public class Animal {
....
@PostPersist
protected void postPersistAnimal() {
System.out.println("Inside Animal.postPersistAnimal()");
}
}

@Entity
@EntityListeners({CatListener.class, CatListener2.class})
public class Cat extends Pet {
...
}

@EntityListeners(SiameseCatListener.class)
@Entity
public class SiameseCat extends Cat {
...
@PostPersist
protected void postPersistAnimal() {
System.out.println("Inside SiameseCat.postPersistAnimal()");
}
}

Here the overridden method SiameseCat.postPersistAnimal() is called and Animal.postPersistAnimal() is not at all called.
reza_rahman (456) [Avatar] Offline
#2
Re: Override Entity Callback Method
Sandeep,

I am really lost here...where is the quote and example from?

Please review the JavaRanch guidelines for posts: http://faq.javaranch.com/java/HowToAskQuestionsOnJavaRanch, particularly the the one about sufficient details on a posting: http://faq.javaranch.com/java/TellTheDetails.

Thanks,
Reza