darrachequesne/spring-data-jpa-datatables-sample

Enum & SearchPanes

VUnguryan opened this issue · 1 comments

I saw that the version was updated to 5.1 and decided to upgrade.

It's great that the search bar support has been added, thanks a lot for removing a bunch of crutches in my code.

But I didn't understand how to work with Enum fields?
I've done it by deleting it from searchPanes and creating my spec for now.

Could you add a Sex field for an Employee and add a use case?

package sample.employee;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.persistence.*;

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Entity
@Table(name = "employees")
public class Employee {
    @Id private int id;
    private String firstName;
    private String lastName;
    private String position;
    private int age;
    private int salary;
   
    @Enumerated(EnumType.STRING) 
    private Sex sex;

    @ManyToOne(cascade = CascadeType.ALL)
    @JoinColumn(name = "id_office")
    private Office office;
    
    enum Sex {
        MALE,
        FEMALE
    }
}