darrachequesne / spring-data-jpa-datatables

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

Plugin doesn't work with @Transient properties in @Entity class #13

Closed ulebule closed 8 years ago

ulebule commented 8 years ago

Hello,

I have some @Transient field in my domain class like this:

...

@Transient
    @JsonView(DataTablesOutput.View.class)
    private OsebaVerzija zadnjaOsebaVerzija;
    public OsebaVerzija getZadnjaOsebaVerzija() {
        return Collections.max(osebaVerzije, new OsebaVerzijaComp());
  }

...

after running my app I get exception in code: ... DataTablesOutput<Oseba> osebas = dtOsebaRepository.findAll(input); ...

Exit: com.test.app.web.rest.OsebaResource.getAllOsebaVerzija() with result = DataTablesOutput [draw=1, recordsTotal=22, recordsFiltered=0, error=java.lang.IllegalArgumentException: Unable to locate Attribute with the the given name [zadnjaOsebaVerzija] on this ManagedType [com.test.app.domain.Oseba]]

darrachequesne commented 8 years ago

Hi! Since that attribute zadnjaOsebaVerzija is not a column of your entity, did you set it to:

orderable : false,
searchable : false,

on the client-side, to prevent any filtering on an unknown column?

If that doesn't solve your issue, I'm afraid I'll need more information (your entity definition and the columns array for datatables, at least) :angel:

darrachequesne commented 8 years ago

@ulebule hi! Did that solve your issue?

ulebule commented 8 years ago

Hi @darrachequesne ! No this is not a solution for me. Because zadnjaOsebaVerzija is class with fields and I need those (few) fields to be orderable and searchable. So I did'nt try this way. I have implemented my own filtering and pagination logic. 10x anyway ;)