-
Notifications
You must be signed in to change notification settings - Fork 202
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
Skip insert/update for @GeneratedValue annotated fields in @Embedded #3344
Conversation
@@ -791,6 +791,13 @@ public JsonDataType getJsonDataType() { | |||
QueryPropertyPath propertyPath = entry.getKey(); | |||
if (entry.getValue() instanceof BindingParameter bindingParameter) { | |||
PersistentEntityUtils.traversePersistentProperties(propertyPath.getPropertyPath(), traverseEmbedded(), (associations, property) -> { | |||
|
|||
boolean generated = PersistentEntityUtils.isPropertyGenerated(entity, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is code that filters persistent properties before building update query, but one of these are embedded and we need to check each fields inside embedded here.
@@ -1026,7 +1027,8 @@ public int getParameterIndex() { | |||
|
|||
for (PersistentProperty prop : persistentProperties) { | |||
traversePersistentProperties(prop, (associations, property) -> { | |||
if (prop.isGenerated()) { | |||
boolean generated = PersistentEntityUtils.isPropertyGenerated(entity, prop, property); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we somehow fix the prop.isGenerated to return true?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does not look like. We have for example Author(id)
which is generated in context of Author
entity insert/update. But, when doing Book
insert/update then it is not generated and it needs to be updatable. This is why we need more context to check if field is generated ie. involved in insert/update.
@@ -861,7 +861,8 @@ public JsonDataType getJsonDataType() { | |||
|
|||
for (PersistentProperty prop : persistentProperties) { | |||
PersistentEntityUtils.traversePersistentProperties(Collections.emptyList(), prop, (associations, property) -> { | |||
if (prop.isGenerated()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like this check was not valid
if (prop.isGenerated()) {
because prop
is property being traversed (either single property or association) and I think we should check property
that is result of prop
traversal.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right
|
This should fix issue