micronaut-data icon indicating copy to clipboard operation
micronaut-data copied to clipboard

PostRemoveEventListener doesn't (always) work for micronaut-data-hibernate-jpa

Open MT-Jacobs opened this issue 3 years ago • 1 comments

Expected Behavior

If I define a PostRemoveEventListener @Singleton, it should work any time that Hibernate detects that the Entity has been removed.

I should expect similar "normal operations" behavior for PostUpdateEventListener and (Hibernate's) PostLoadEventListener.

Actual Behaviour

The PostRemoveEventListener only works if I also define a PostPersistEventListener. See PR listed in repro steps for more info on a fix/cause.

Steps To Reproduce

If I define a simple delete listener:

@Factory
class ContractListeners {
    private val logger = KotlinLogging.logger {}
    @Singleton
    fun postContractDelete(): PostRemoveEventListener<Contract> =
        PostRemoveEventListener { contract: Contract ->
            logger.info { "I deleted it." }
        }
}

All I need to do is delete the Contract and notice that it doesn't trigger the listener.

I should see an info log on delete.

Additional Notes:

I believe I've isolated the root cause and have a fix PR here - https://github.com/micronaut-projects/micronaut-data/pull/1755 It's not just 3.6.1 - this is on the the current latest, 3.8.0 too. It's been around for a while!

All that said, I just wanted to make it easier to categorize this issue as a bug. Hopefully this was the right way to go about that!

Environment Information

No response

Example Application

No response

Version

3.6.1

MT-Jacobs avatar Sep 21 '22 23:09 MT-Jacobs

Found more bugged listener behavior and added it to the description.

MT-Jacobs avatar Sep 22 '22 16:09 MT-Jacobs