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

EntityHooks are not invoked when using DSL API #1706

Open
Nek-12 opened this issue Mar 19, 2023 · 1 comment
Open

EntityHooks are not invoked when using DSL API #1706

Nek-12 opened this issue Mar 19, 2023 · 1 comment

Comments

@Nek-12
Copy link

Nek-12 commented Mar 19, 2023

I'm using an EntityHook to sign up for changes in the database. When an entry is deleted, I want to create an entry in another table.
My problem is that when I'm using a Table.deleteWhere() clause, EntityHook is not invoked.
The only place where that entity hook is invoked, judging by the source code, is when the delete() method of the entity is called
(Entity.kt line 249)

I want to listen to changes on any operation on a given table. How can I do this without using database triggers?

@MJavoso
Copy link

MJavoso commented Sep 28, 2024

I could resolve this issue by creating special functions, but I guess this is not what you want, since EntityHook and StatementInterceptors have separated mechanics.

What I did was creating special functions that only should be used when making a CRUD operation, else, a normal transaction block would be used for selecting values. These functions had a lambda parameter called onDatabaseChanged, and, with the use of flows, emit the changes from the readers. It is quite complex so if you want to see the sample code just reply.

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

No branches or pull requests

2 participants