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

FEATURE: Disable overwriting generated properties at transaction level #2943

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

rPraml
Copy link
Contributor

@rPraml rPraml commented Jan 23, 2023

We want to backup & restore some data by exporting it to JSON. For this use case we need to preserve

  • whenCreated
  • whoCreated
  • whenModified
  • whoModified

This PR allows to disable the update of these properties for a particular transaction

@rPraml rPraml force-pushed the no-overwite-generated-props branch from 2ff97fc to effc0da Compare January 23, 2023 15:31
@rbygrave
Copy link
Member

rbygrave commented Feb 1, 2023

I like the feature.

When I first read it I expect the opposite meaning for overwriteGeneratedProperties = true ... which to me means I the developer get to override the generated properties. I want to set it to true to enable me the developer to override the values of the generated properties. Currently in the PR it has the opposite meaning.

I'll ponder this ...

@rPraml
Copy link
Contributor Author

rPraml commented Feb 2, 2023

That depends on which side you look at it from:

  • do the developer want to overwrite the generated propertes (and ebean shouldn't set them back)
  • or should NOT ebean overwrite previously changed propertes.

I agree, after your comment, the name is not the best. I'm sure we'll find an other one

  • noUpdateGenerated (butIfTheyAreNullSetThem) - also a point of view problem
  • disableGeneratedUpdate
  • ...

@rPraml rPraml changed the title NEW: Feature to disable overwriting generated properties FEATURE: Disable overwriting generated properties at transaction level Aug 8, 2023
@jnehlmeier
Copy link

Is it allowed to toggle that switch on/off during the lifespan of the transaction or would that miserably cause problems? If it can be toggled on/off at any time then a setter name seems fine, e.g. setAutoUpdateGeneratedFields(boolean). If we can not toggle the setting at any time then just disableAutoUpdateGeneratedFields() to disable the default setting.

Side note: It would be so cool if that whole generated fields thing would be extendible/configurable. For example I like Who/WhenDeleted as well, because soft-deletion is not a modification of data.

@rPraml
Copy link
Contributor Author

rPraml commented Aug 8, 2023

Generated properties are updated during save, so it is possible to modify it at nearly any time
(you might not change it in a persist callback or in an other thread).

setAutoUpdateGeneratedFields(boolean)

I like that name

rPraml added a commit to FOCONIS/ebean that referenced this pull request Aug 10, 2023
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 this pull request may close these issues.

None yet

3 participants