File tree Expand file tree Collapse file tree 5 files changed +22
-26
lines changed
main/java/org/springframework/data/jpa/datatables
test/java/org/springframework/data/jpa/datatables Expand file tree Collapse file tree 5 files changed +22
-26
lines changed Original file line number Diff line number Diff line change 64
64
<dependency >
65
65
<groupId >org.springframework.boot</groupId >
66
66
<artifactId >spring-boot-dependencies</artifactId >
67
- <version >2.3.9.RELEASE </version >
67
+ <version >2.6.7 </version >
68
68
<type >pom</type >
69
69
<scope >import</scope >
70
70
</dependency >
Original file line number Diff line number Diff line change @@ -126,6 +126,11 @@ public boolean hasPrevious() {
126
126
public int getPageNumber () {
127
127
throw new UnsupportedOperationException ();
128
128
}
129
+
130
+ @ Override
131
+ public Pageable withPage (int pageNumber ) {
132
+ throw new UnsupportedOperationException ();
133
+ }
129
134
}
130
135
131
136
}
Original file line number Diff line number Diff line change 18
18
19
19
import javax .sql .DataSource ;
20
20
import java .sql .SQLException ;
21
+ import java .util .Properties ;
21
22
22
23
/**
23
24
* Spring JavaConfig configuration for general infrastructure.
@@ -61,23 +62,13 @@ public SessionFactory entityManagerFactory(DataSource dataSource) throws Excepti
61
62
LocalSessionFactoryBean factory = new LocalSessionFactoryBean ();
62
63
factory .setPackagesToScan (Config .class .getPackage ().getName ());
63
64
factory .setDataSource (dataSource );
64
- factory .afterPropertiesSet ();
65
- return factory .getObject ();
66
- }
67
-
68
- @ Bean
69
- public AbstractEntityManagerFactoryBean entityManager (DataSource dataSource )
70
- throws SQLException {
71
-
72
- HibernateJpaVendorAdapter jpaVendorAdapter = new HibernateJpaVendorAdapter ();
73
- jpaVendorAdapter .setGenerateDdl (true );
74
65
75
- LocalContainerEntityManagerFactoryBean bean = new LocalContainerEntityManagerFactoryBean ();
76
- bean .setJpaVendorAdapter (jpaVendorAdapter );
77
- bean .setPackagesToScan (Config .class .getPackage ().getName ());
78
- bean .setDataSource (dataSource );
66
+ Properties properties = new Properties ();
67
+ properties .setProperty ("hibernate.hbm2ddl.auto" , "create" );
68
+ factory .setHibernateProperties (properties );
79
69
80
- return bean ;
70
+ factory .afterPropertiesSet ();
71
+ return factory .getObject ();
81
72
}
82
73
83
74
@ Bean
Original file line number Diff line number Diff line change 7
7
import lombok .experimental .Tolerate ;
8
8
9
9
import javax .persistence .*;
10
+ import java .util .Comparator ;
10
11
import java .util .List ;
12
+ import java .util .stream .Collectors ;
11
13
12
14
import static java .util .Arrays .asList ;
15
+ import static java .util .Comparator .comparingInt ;
16
+ import static java .util .Comparator .reverseOrder ;
17
+ import static java .util .stream .Collectors .toList ;
13
18
14
19
@ Data
15
20
@ Setter (AccessLevel .NONE )
@@ -102,13 +107,9 @@ private Employee() {}
102
107
BRIELLE_WILLIAMSON
103
108
);
104
109
105
- public static List <Employee > ALL_SORTED_BY_AGE = asList (
106
- BRENDEN_WAGNER ,
107
- AIRI_SATOU ,
108
- BRADLEY_GREER ,
109
- ANGELICA_RAMOS ,
110
- BRIELLE_WILLIAMSON ,
111
- ASHTON_COX
112
- );
110
+ public static List <Employee > ALL_SORTED_BY_AGE =
111
+ ALL .stream ().sorted (comparingInt (e -> e .age )).collect (toList ());
113
112
113
+ public static List <Employee > ALL_SORTED_BY_AGE_DESC =
114
+ ALL .stream ().sorted (comparingInt (e -> -e .age )).collect (toList ());
114
115
}
Original file line number Diff line number Diff line change 1
1
package org .springframework .data .jpa .datatables .repository ;
2
2
3
- import com .google .common .collect .Lists ;
4
3
import org .junit .Before ;
5
4
import org .junit .Test ;
6
5
import org .junit .runner .RunWith ;
@@ -88,7 +87,7 @@ public void sortDescending() {
88
87
input .addOrder ("age" , false );
89
88
90
89
DataTablesOutput <Employee > output = getOutput (input );
91
- assertThat (output .getData ()).containsExactlyElementsOf (Lists . reverse ( Employee .ALL_SORTED_BY_AGE ) );
90
+ assertThat (output .getData ()).containsExactlyElementsOf (Employee .ALL_SORTED_BY_AGE_DESC );
92
91
}
93
92
94
93
@ Test
You can’t perform that action at this time.
0 commit comments