darrachequesne / spring-data-jpa-datatables

Spring Data JPA extension to work with the great jQuery plugin DataTables (https://datatables.net/)
Apache License 2.0
440 stars 174 forks source link

Search Panes Error in Relationship Table #159

Open FluffyKnight2002 opened 3 months ago

FluffyKnight2002 commented 3 months ago

I can use search panes with data from relationship entity.

@RequestMapping(value = "/employees-searchpanes-basic", method = RequestMethod.POST) public DataTablesOutput listWithBasicSearchPanes(@Valid DataTablesInput input, @RequestParam Map<String, String> queryParameters) { input.parseSearchPanesFromQueryParams(queryParameters, Arrays.asList("position", "office.city")); return employeeRepository.findAll(input); }

I want to use office.city in SearchPanes and but when i use like this, 'DataTables warning: table id=employees - java.lang.IllegalArgumentException: org.hibernate.query.SemanticException: Could not resolve attribute 'office.city' of 'sample.employee.Employee' that error happen. How do i fix that?

darrachequesne commented 3 months ago

I could indeed reproduce the issue. It seems there is a mistake here: https://github.com/darrachequesne/spring-data-jpa-datatables/blob/be286ee3fd44a106d70cf284f08024cb2e5c0351/src/main/java/org/springframework/data/jpa/datatables/repository/DataTablesRepositoryImpl.java#L112-L113

I think root.get(attribute) (here, root.get("office.city")) is not valid, the string should be split into root.get("office").get("city"). Would you have time to create a PR?

FluffyKnight2002 commented 3 months ago

i dont know how to do that?

darrachequesne commented 3 months ago

This should be fixed by https://github.com/darrachequesne/spring-data-jpa-datatables/commit/495cfbc4cf6e110bf7b6dcb47d7bfd8587056169, which was included in version 6.0.4. Could you please check?