Skip to content

using a ReactiveRepository to save a new entry with user-provided id doesn't persists the entity #110

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

Closed
cambierr opened this issue May 5, 2019 · 2 comments
Labels
for: stackoverflow A question that's better suited to stackoverflow.com

Comments

@cambierr
Copy link

cambierr commented May 5, 2019

I just noticed that the .save(Entity entity method doesn't actually saves anything if the entity id is user-provided instead of created by the database (Postgres in my case).

For now, the only workaround I see is to add another id property that can be auto-generated but this is a hugly workaround.

From my understanding, this seems to be due to EntityInformation.isNew(T entity) checking if the id property is different from null.

How could we work around this ?

@mp911de mp911de added the for: stackoverflow A question that's better suited to stackoverflow.com label May 5, 2019
@mp911de
Copy link
Member

mp911de commented May 5, 2019

Repositories assume by new/existing state based on the id. If the entity is null, then we assume the entity is new. You can implement Persistable which provides theisNew() method which is used then to determine whether your entity is new or whether it should be expected to exist.

We have no support yet for optimistic locking (see #93) where we could use a @Version property to determine new/existing state.

@mp911de mp911de closed this as completed May 5, 2019
@cambierr
Copy link
Author

cambierr commented May 6, 2019

Didn't know about that interface ! thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
for: stackoverflow A question that's better suited to stackoverflow.com
Projects
None yet
Development

No branches or pull requests

2 participants