Closed RomanKurbanov closed 1 year ago
For future readers:
The problem is that we cannot know why the field is marked as non-searchable, it might be a rendered column. You can manually fetch lazy fields with an additional specification though:
@RestController
public class MyController {
@RequestMapping(value = "/entities", method = RequestMethod.GET)
public DataTablesOutput<MyEntity> list(@Valid DataTablesInput input) {
return myRepository.findAll(input, (root, query, criteriaBuilder) -> {
if (query.getResultType() != Long.class) {
root.fetch("relatedEntity", JoinType.LEFT);
}
return null;
});
}
}
Reference: https://github.com/darrachequesne/spring-data-jpa-datatables#fetch-lazy-fields
If we declare a field as non-searchable:
Then lazy-loaded field (office) won't be initialised