I'm using spring data.
I'm trying to do a generic search who will add all field of the class in specification
public abstract class BaseRepository<T, R> extends SimpleJpaRepository implements IBaseRepository<T, R> {
@PersistenceContext
private EntityManager em;
@Autowired
public BaseRepository(Class<T> domainClass, EntityManager em) {
super(domainClass, em);
}
@Override
public Page<T> advancedSearch(R r, Pageable page) {
Specification<T> specification = (Root<T> root, CriteriaQuery<?> cq, CriteriaBuilder cb) -> {
Predicate p = cb.conjunction();
//how to access field of T
return p;
};
return this.findAll(specification, page);
}
}
How can I access field of T?
Aucun commentaire:
Enregistrer un commentaire