-
Notifications
You must be signed in to change notification settings - Fork 57
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
Handling of @Id and @Version fields in AutoCrud could be improved #2809
Comments
See #2217 specifically about the errors from hidden fields. Besides that, we could assume |
I think I need to add some more context. I detected a typo in my example code @Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private long id; For some reason I don't understand, I used Using Using |
Describe the bug
When you have a JPA entity with a field annotated with
@Id
or@Version
and you use this entity in the AutoCrud component, you likely won't be able to submit the form of the AutoCrud component. You can fill the form and press submit, but nothing will happen, and you won't see any errors in the frontend or backend.Hilla validates these fields already on the client, but the error is never shown because AutoCrud / AutoForm hide fields for id and version automatically. So there are client-side validation errors, but they are not visible. The values for id and version fields are generated only on the server after saving an entity.
A workaround is to add the
@com.vaadin.hilla.Nullable
annotation to the id and/or version field of the JPA entity, but this feels strange. From a developer perspective, I want this fields to be not empty nor null, and I know, that JPA will take care of this.Expected-behavior
Using the annotations
@Id
and@Version
is quite common. As a developer, I want to use entities with these annotations in the AutoCrud component with a good developer experience. This could mean:console.error
or a notification or a popup/popover.Reproduction
@Id
and/or@Version
annotationsSystem Info
Vaadin 24.5.0.beta6
The text was updated successfully, but these errors were encountered: