Skip to content

Feature/Support for QueryValue as a object #11787

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

Open
wants to merge 9 commits into
base: 4.9.x
Choose a base branch
from

Conversation

MarianConstantinMarica
Copy link

No description provided.

@CLAassistant
Copy link

CLAassistant commented Apr 28, 2025

CLA assistant check
All committers have signed the CLA.

@yawkat yawkat requested a review from dstepanov April 28, 2025 19:02
@yawkat
Copy link
Member

yawkat commented Apr 28, 2025

@dstepanov can you think of a better way to do this? otherwise i think it's ok

BeanIntrospection<T> introspection = introspectionOpt.get();
T instance;
try {
instance = introspection.instantiate();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why no-args constructor is required? I'think you need more tests with record and required args constructor (without no-arg)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will update!

return BindingResult.unsatisfied();
}

BeanIntrospection<T> introspection = introspectionOpt.get();
Copy link
Contributor

@graemerocher graemerocher Apr 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be altered to use introspection.builder() so that records, immutable types, types with custom constructors etc. are supported.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When using IntrospectionBuilder API and finally call the build() method any exception should b caught and the conversion rejected with context.reject

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made the changes with the introspection.builder(). Seems to work for object with custom constructor but I made a test for record and don't work. Am I missing something?

BeanIntrospection<T> introspection = introspectionOpt.get();
BeanIntrospection.Builder<T> introspectionBuilder = introspection.builder();

for (BeanProperty<T, Object> property : introspection.getBeanProperties()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

iterative here over the getBuilderArguments() using array iteration to obtain the index

Optional<Object> converted = conversionService.convert(value.get(), context.with(property.asArgument()));
if (converted.isPresent()) {
try {
introspectionBuilder.with(propertyName, converted.get());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried with getBuilderArguments() iteration, still not working for the records

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

Successfully merging this pull request may close these issues.

5 participants