@@ -24,7 +24,7 @@ public class UserRestController {
24
24
25
25
## Maven dependency
26
26
27
- ```
27
+ ``` xml
28
28
<dependency >
29
29
<groupId >com.github.darrachequesne</groupId >
30
30
<artifactId >spring-data-jpa-datatables</artifactId >
@@ -39,11 +39,11 @@ Please see the [sample project](https://github.com/darrachequesne/spring-data-jp
39
39
#### 1. Enable the use of ` DataTablesRepository ` factory
40
40
41
41
With either
42
- ```
42
+ ``` java
43
43
@EnableJpaRepositories (repositoryFactoryBeanClass = DataTablesRepositoryFactoryBean . class)
44
44
```
45
45
or its XML counterpart
46
- ```
46
+ ``` xml
47
47
<jpa : repositories factory-class =" org.springframework.data.jpa.datatables.repository.DataTablesRepositoryFactoryBean" />
48
48
```
49
49
@@ -88,23 +88,36 @@ It overrides jQuery data serialization to allow Spring MVC to correctly map inpu
88
88
#### On the server-side
89
89
90
90
The 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
+ ```
96
103
97
104
** Note** : since version 2.0, QueryDSL is also supported:
98
105
* replace ` DataTablesRepositoryFactoryBean ` with ` QDataTablesRepositoryFactoryBean `
99
106
* replace ` DataTablesRepository ` with ` QDataTablesRepository `
100
107
101
108
and your repositories will now expose:
102
109
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
+ ```
108
121
109
122
Your controllers should be able to handle the parameters sent by DataTables:
110
123
@@ -216,3 +229,17 @@ Supported filters:
216
229
Also supports paging and sorting.
217
230
218
231
**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