Spring JPA QuerydslPredicate Snake Case
up vote
0
down vote
favorite
I am using spring boot with Query DSL. I have configured my spring boot to use snake case i.e. spring.jackson.property-naming-strategy=SNAKE_CASE. So my json payload input and output is in snake case like below
{
"first_name": "First",
"last_name": "Last"
}
I am using @QuerydslPredicate for my search functionality. If I enter query params in snake case like below
(http://localhost:8080/context/resource/?first_name=First)
it is not parsed by Query DSL Predicate. However, If I provide the params in camel case like below
(http://localhost:8080/context/resource/?firsName=First)
it works fine. This is not synonymous with json structure.
How can I achieve snake case in query params so that Query DSL parses it?
This is how my REST end point looks like
@GetMapping
public ResponseEntity<Output> listUsers(@QuerydslPredicate(root = User.class) Predicate predicate, Pageable pageable) {
...
return new ResponseEntity<>(output, HttpStatus.OK);
}
PN: My Model Object is in camel case like below
Model Object
public class User {
private String firstName;
private String lastName;
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
}
I came across a solution on HandlerMethodArgumentResolver, but that is lot of work. There should be a way to automate it than doing all model fields.
spring-boot querydsl predicate
add a comment |
up vote
0
down vote
favorite
I am using spring boot with Query DSL. I have configured my spring boot to use snake case i.e. spring.jackson.property-naming-strategy=SNAKE_CASE. So my json payload input and output is in snake case like below
{
"first_name": "First",
"last_name": "Last"
}
I am using @QuerydslPredicate for my search functionality. If I enter query params in snake case like below
(http://localhost:8080/context/resource/?first_name=First)
it is not parsed by Query DSL Predicate. However, If I provide the params in camel case like below
(http://localhost:8080/context/resource/?firsName=First)
it works fine. This is not synonymous with json structure.
How can I achieve snake case in query params so that Query DSL parses it?
This is how my REST end point looks like
@GetMapping
public ResponseEntity<Output> listUsers(@QuerydslPredicate(root = User.class) Predicate predicate, Pageable pageable) {
...
return new ResponseEntity<>(output, HttpStatus.OK);
}
PN: My Model Object is in camel case like below
Model Object
public class User {
private String firstName;
private String lastName;
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
}
I came across a solution on HandlerMethodArgumentResolver, but that is lot of work. There should be a way to automate it than doing all model fields.
spring-boot querydsl predicate
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I am using spring boot with Query DSL. I have configured my spring boot to use snake case i.e. spring.jackson.property-naming-strategy=SNAKE_CASE. So my json payload input and output is in snake case like below
{
"first_name": "First",
"last_name": "Last"
}
I am using @QuerydslPredicate for my search functionality. If I enter query params in snake case like below
(http://localhost:8080/context/resource/?first_name=First)
it is not parsed by Query DSL Predicate. However, If I provide the params in camel case like below
(http://localhost:8080/context/resource/?firsName=First)
it works fine. This is not synonymous with json structure.
How can I achieve snake case in query params so that Query DSL parses it?
This is how my REST end point looks like
@GetMapping
public ResponseEntity<Output> listUsers(@QuerydslPredicate(root = User.class) Predicate predicate, Pageable pageable) {
...
return new ResponseEntity<>(output, HttpStatus.OK);
}
PN: My Model Object is in camel case like below
Model Object
public class User {
private String firstName;
private String lastName;
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
}
I came across a solution on HandlerMethodArgumentResolver, but that is lot of work. There should be a way to automate it than doing all model fields.
spring-boot querydsl predicate
I am using spring boot with Query DSL. I have configured my spring boot to use snake case i.e. spring.jackson.property-naming-strategy=SNAKE_CASE. So my json payload input and output is in snake case like below
{
"first_name": "First",
"last_name": "Last"
}
I am using @QuerydslPredicate for my search functionality. If I enter query params in snake case like below
(http://localhost:8080/context/resource/?first_name=First)
it is not parsed by Query DSL Predicate. However, If I provide the params in camel case like below
(http://localhost:8080/context/resource/?firsName=First)
it works fine. This is not synonymous with json structure.
How can I achieve snake case in query params so that Query DSL parses it?
This is how my REST end point looks like
@GetMapping
public ResponseEntity<Output> listUsers(@QuerydslPredicate(root = User.class) Predicate predicate, Pageable pageable) {
...
return new ResponseEntity<>(output, HttpStatus.OK);
}
PN: My Model Object is in camel case like below
Model Object
public class User {
private String firstName;
private String lastName;
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
}
I came across a solution on HandlerMethodArgumentResolver, but that is lot of work. There should be a way to automate it than doing all model fields.
spring-boot querydsl predicate
spring-boot querydsl predicate
edited Nov 13 at 5:22
asked Nov 13 at 4:45
Maz
135312
135312
add a comment |
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53273966%2fspring-jpa-querydslpredicate-snake-case%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown