@@ -24,7 +24,7 @@ public class UserRestController {
2424
2525## Maven dependency
2626
27- ```
27+ ``` xml
2828<dependency >
2929<groupId >com.github.darrachequesne</groupId >
3030<artifactId >spring-data-jpa-datatables</artifactId >
@@ -39,11 +39,11 @@ Please see the [sample project](https://github.com/darrachequesne/spring-data-jp
3939#### 1. Enable the use of ` DataTablesRepository ` factory
4040
4141With either
42- ```
42+ ``` java
4343@EnableJpaRepositories (repositoryFactoryBeanClass = DataTablesRepositoryFactoryBean . class)
4444```
4545or its XML counterpart
46- ```
46+ ``` xml
4747<jpa : repositories factory-class =" org.springframework.data.jpa.datatables.repository.DataTablesRepositoryFactoryBean" />
4848```
4949
@@ -88,23 +88,36 @@ It overrides jQuery data serialization to allow Spring MVC to correctly map inpu
8888#### On the server-side
8989
9090The repositories now expose the following methods:
91- * ` DataTablesOutput<T> findAll(DataTablesInput i); `
92- * ` DataTablesOutput<R> findAll(DataTablesInput i, Converter<T, R> c); `
93- * ` DataTablesOutput<T> findAll(DataTablesInput i, Specification<T> a); `
94- * ` DataTablesOutput<T> findAll(DataTablesInput i, Specification<T> a, Specification<T> p); `
95- * ` DataTablesOutput<R> findAll(DataTablesInput i, Specification<T> a, Specification<T> p, Converter<T, R> c); `
91+
92+ ``` java
93+ DataTablesOutput<T > findAll(DataTablesInput input);
94+ DataTablesOutput<R > findAll(DataTablesInput input, Function<T , R > converter);
95+ DataTablesOutput<T > findAll(DataTablesInput input, Specification<T > additionalSpecification);
96+
97+ DataTablesOutput<T > findAll(DataTablesInput input, Specification<T > additionalSpecification,
98+ Specification<T > preFilteringSpecification);
99+
100+ DataTablesOutput<R > findAll(DataTablesInput input, Specification<T > additionalSpecification,
101+ Specification<T > preFilteringSpecification, Function<T , R > converter);
102+ ```
96103
97104** Note** : since version 2.0, QueryDSL is also supported:
98105* replace ` DataTablesRepositoryFactoryBean ` with ` QDataTablesRepositoryFactoryBean `
99106* replace ` DataTablesRepository ` with ` QDataTablesRepository `
100107
101108and your repositories will now expose:
102109
103- * ` DataTablesOutput<T> findAll(DataTablesInput i); `
104- * ` DataTablesOutput<R> findAll(DataTablesInput i, Converter<T, R> c); `
105- * ` DataTablesOutput<T> findAll(DataTablesInput i, com.mysema.querydsl.Predicate a); `
106- * ` DataTablesOutput<T> findAll(DataTablesInput i, com.mysema.querydsl.Predicate a, com.mysema.querydsl.Predicate p); `
107- * ` DataTablesOutput<R> findAll(DataTablesInput i, com.mysema.querydsl.Predicate a, com.mysema.querydsl.Predicate p, Converter<T, R> c); `
110+ ``` java
111+ DataTablesOutput<T > findAll(DataTablesInput input);
112+ DataTablesOutput<R > findAll(DataTablesInput input, Function<T , R > converter);
113+ DataTablesOutput<T > findAll(DataTablesInput input, Predicate additionalPredicate);
114+
115+ DataTablesOutput<T > findAll(DataTablesInput input, Predicate additionalPredicate,
116+ Predicate preFilteringPredicate);
117+
118+ DataTablesOutput<R > findAll(DataTablesInput input, Predicate additionalPredicate,
119+ Predicate preFilteringPredicate, Function<T , R > converter);
120+ ```
108121
109122Your controllers should be able to handle the parameters sent by DataTables:
110123
@@ -216,3 +229,17 @@ Supported filters:
216229Also supports paging and sorting.
217230
218231**Note**: the ` regex` flag is currently ignored because JPQL only supports ` LIKE ` expressions (with ` % ` and ` _` tokens).
232+
233+ Yet you should be able to use the DBMS-specific regex operator with the ` CriteriaBuilder .function ()` method.
234+
235+ Example with H2 [REGEXP_LIKE](http://www.h2database.com/html/functions.html#regexp_like):
236+
237+ ` ` ` java
238+ Column column = input .getColumn (" my_column" );
239+ column .setSearchable (false ); // so the default filter will not be applied
240+ String regexValue = column .getSearch ().getValue ();
241+ DataTablesOutput< ... > output = repository .findAll (input, (root, query, builder) - > {
242+ Expression< String > regex = builder .function (" REGEXP_LIKE" , String .class , root .get (" my_column" ), builder .literal (regexValue));
243+ return builder .equal (regex, builder .literal (1 ));
244+ });
245+ ` ` `
0 commit comments