Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lifecycle CDI Event #373

Open
hantsy opened this issue Nov 23, 2023 · 5 comments · Fixed by #876
Open

Lifecycle CDI Event #373

hantsy opened this issue Nov 23, 2023 · 5 comments · Fixed by #876
Milestone

Comments

@hantsy
Copy link

hantsy commented Nov 23, 2023

Like the JPA event listener and do side effect by annotations @Save, @Merge, etc(till now I do not know well about the purpose of these annotations).

Spring Data provides a collection of XXXCallback when converting/saving/updating/delete an entity object.

In Jakarta Data, we can introduce CDI Event instead, make it compatible with all implementation modules.

It is more freely for developers.

@otaviojava otaviojava added this to the Jakarta Data Future milestone Nov 23, 2023
@gavinking
Copy link
Contributor

In Jakarta Data, we can introduce CDI Event instead, make it compatible with all implementation modules.

It's an appealing idea to use the CDI event bus for this, actually. Definitely worth considering in future.

[But I doubt it's a priority for 1.0.]

@njr-11 njr-11 modified the milestones: Jakarta Data Future, 1.1 Oct 10, 2024
@gavinking
Copy link
Contributor

I have now received a few requests for this.

I think it would be extremely straightforward to define event types corresponding to our lifecycle operations, e.g. PostUpdateEvent, PreInsertEvent, etc, and specify that a repository should route them to the CDI event bus so that a CDI component can receive them via @Observes.

gavinking added a commit to gavinking/data that referenced this issue Oct 24, 2024
see jakartaee#373

Signed-off-by: Gavin King <gavin@hibernate.org>
gavinking added a commit to gavinking/data that referenced this issue Oct 24, 2024
see jakartaee#373

Signed-off-by: Gavin King <gavin@hibernate.org>
@gavinking gavinking linked a pull request Oct 24, 2024 that will close this issue
@njr-11
Copy link
Contributor

njr-11 commented Nov 21, 2024

Reopen this because we will still need to add TCK tests for the function.

@njr-11 njr-11 reopened this Nov 21, 2024
@gavinking
Copy link
Contributor

I think I'll take a crack at implementing this tonight, make sure it actually works...

@gavinking
Copy link
Contributor

I think I'll take a crack at implementing this tonight, make sure it actually works...

Just implemented it. Works beautifully. Love it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants