-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Fix #1516: Support @JsonManagedReference/@JsonBackReference for property-based creators #5486
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
base: 3.x
Are you sure you want to change the base?
Fix #1516: Support @JsonManagedReference/@JsonBackReference for property-based creators #5486
Conversation
|
@cowtowncoder |
| } | ||
|
|
||
| // [databind#1516]: Inject back references for managed reference creator properties | ||
| for (SettableBeanProperty prop : creator.properties()) { |
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.
Should optimize so we don't always iterate over all properties (there should be a flag to indicate if we have any managed ref props, I think)
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.
That makes sense.
I agree that iterating over all properties unconditionally is unnecessary.
I’ll look into adding a lightweight flag to indicate whether any managed reference properties are present, so that we only perform the iteration when it’s actually needed.
Thank you :)
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.
Thank you for your advice.
I’ve implemented the change accordingly and pushed the commit.
| import static org.junit.jupiter.api.Assertions.*; | ||
|
|
||
| // [databind#1516] | ||
| public class TestKotlinGithub129 extends DatabindTestUtil |
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.
Naming: should end with Test, not start
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.
I’ll make sure to keep this in mind as well.
Thank you again :)
|
Looks promising: I'll try to review soon -- next PR on my list to handle. |
Issue: #1516
I resolved the issue where
@JsonManagedReferenceand@JsonBackReferenceannotations didn't work when used with property-based creators (@ConstructorProperties).In addition, I added a test case in
TestKotlinGithub129to verify the fix.This test is based on
testGithub129()inTestGithub149class from [jackson-module-kotlin].