question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

EntityHook: Duplicate EntityChanges per transaction

See original GitHub issue

I have a question about the entity hook and the registered entity changes.

https://github.com/JetBrains/Exposed/blob/7e3c74232406b1d60609a5b8a856a7bffe4a8135/exposed-dao/src/main/kotlin/org/jetbrains/exposed/dao/EntityHook.kt#L37-L41

When a change gets registered there is a check if that change was already registered. But the code above only checks if the last added change is equal to the current change. If there was a different change in the meantime the duplicate change will be registered anyhow. I’m not sure if this is on purpose but I would consider all changes on the same entity in the same transaction to be ‘one’ change in any case (also if there are changes on other entities in between). So I would change the code to this:

fun registerChange(transaction: Transaction, change: EntityChange) { 
     if (change !in transaction.entityEvents) { 
         transaction.entityEvents.add(change) 
     } 
 } 

What is your opinion about this?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
mpe85commented, Dec 14, 2019

@Tapac Thanks for the feedback. What would also help is to provide some kind of transaction identifier in the entity change event so the subscribers know which events were triggered within the same transaction. Maybe each transaction could have a unique UUID which is used for this. What do you think?

0reactions
Tapaccommented, Dec 27, 2019

Released in 0.20.1

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to intercept entity changes with Hibernate event listeners
Learn how to intercept entity changes (persist, merge, remove) using Hibernate event listeners and replicate changes to other database ...
Read more >
Test data creation with Kotlin DSL and Exposed - neetkee.com
In this post, I will describe how you can use the power of Kotlin DSL and Exposed for test entities creation. If you...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found