Could you tell me how to pass sort param to rest controller in snake_case format?
My entity class
@Entity
public class MyEntity extends BaseEntity{
@Id
private Long id;
@Column
private Long parentId;
}
Controller method
@GetMapping("list")
List<MyEntity> getEntityList(
@PageableDefault(sort = {"id"}, direction = Sort.Direction.DESC) Pageable pageable);
}
In request i want to use ?sort=parent_id
I've created Jackson2ObjectMapperBuilder and it builds correct snake_case json
But spring send me Caused by: org.springframework.data.mapping.PropertyReferenceException: No property parent found for type MyEntity! Did you mean 'parentId'?
I think this is issue about parsing because spring cut everything after '_' symbol.
I've tried:
- @JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class)
- @Column(name = "parent_id") @JsonProperty("parent_id")
- @JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class)