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

Exceptions aren't thrown on updates if entities don't have an id assigned #3049

Open
Nahuel92 opened this issue Aug 4, 2024 · 0 comments
Open

Comments

@Nahuel92
Copy link

Nahuel92 commented Aug 4, 2024

Expected Behavior

As per #CrudRepostory.update JavaDocs:

This method issues an explicit update for the given entity. The method differs from save(Object) in that an update will be generated regardless if the entity has been saved previously or not. If the entity has no assigned ID then an exception will be thrown.

Last sentence is key.

Actual Behaviour

Exceptions are not thrown and updates on entities without IDs assigned are silently ignored.

Steps To Reproduce

You can see the example app provided, but steps are:

  1. Create an app with latest Micronaut version and Micronaut Data JDBC and H2.
  2. Create a simple entity and a @JdbcRepository for this entity.
  3. Create a test where you create an entity, then remove the ID for this entity and try to update it. You can also use SQL scripts to achieve the same result.

Environment Information

  • OS: Windows/MacOS (I don't think it matters)
  • Java: 21 (I don't think it matters either).

Example Application

https://github.com/Nahuel92/micronaut-data-update-bug

Version

4.5.1

@Nahuel92 Nahuel92 changed the title Exceptions aren't thrown on updates if entity don't have an id assigned Exceptions aren't thrown on updates if entities don't have an id assigned Aug 5, 2024
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

1 participant