-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Add camelCase
to snake_case
fallback for native query projections
#3462
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
Comments
The column name is |
Hi, @quaff, thanks for the answer.
This would become very inefficient and unmaintainable to write out all individual fields for selection, wouldn't it?
But this is not going to change the fact that when using native and non-native queries the return value is interpreted differently? I use PostgreSQL and return values are snake like full_name, also when submitting they have to be snake case. Cheers. |
I agree, It would be great if Spring Data JPA handle it like |
…e for projecting native query > By default, Spring Boot configures the physical naming strategy with CamelCaseToUnderscoresNamingStrategy. Then we should convert underscores back to camel case. Fix spring-projectsGH-3462
…e for projecting native query > By default, Spring Boot configures the physical naming strategy with CamelCaseToUnderscoresNamingStrategy. Then we should convert underscores back to camel case. Fix spring-projectsGH-3462
Please provide a minimal yet complete sample that reproduces the problem. |
You can reproduce it by running the added test in (#3472) |
There's an easier approach by using |
camelCase
to snake_case
fallback for native query projections
…e for projecting native query > By default, Spring Boot configures the physical naming strategy with CamelCaseToUnderscoresNamingStrategy. Then we should convert underscores back to camel case. Fix spring-projectsGH-3462
…e for projecting native query > By default, Spring Boot configures the physical naming strategy with CamelCaseToUnderscoresNamingStrategy. Then we should convert underscores back to camel case. Fix spring-projectsGH-3462
Hello, I have my Friend repository class from friend Modulith module:
For testing purposes I will create simple function to get users within Friend repository:
The interface for the User entity is:
The User entity has these fields (others emitted):
However, the REST API returns null on fullName field.
How does that work exactly? Why my projection fails for camel case fields when projection class (in this instance UserProjection is in different module?
--------------------- EDIT ---------------------
Okay, so I finally understood what was happening. I had to create two projection classes, one for functions that use native query and one for those who do not.
For functions that use native query, interface projection for camel case fields must be specified as:
for projection that do not use native queries, I can use:
I still do not understand why is that. Is there a more appropriate solution for using only single projection so it would satisfy both native and non native queries? Cheers.
The text was updated successfully, but these errors were encountered: