Skip to content

Commit 69bc80d

Browse files
committed
Move to Spring Boot 4
1 parent 523e450 commit 69bc80d

File tree

10 files changed

+111
-67
lines changed

10 files changed

+111
-67
lines changed

core/src/main/java/com/cosium/spring/data/jpa/entity/graph/repository/EntityGraphCrudRepository.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,20 @@
1212
*/
1313
@NoRepositoryBean
1414
public interface EntityGraphCrudRepository<T, ID>
15-
extends CrudRepository<T, ID>, EntityGraphRepository<T, ID> {
15+
extends EntityGraphRepository<T, ID>, CrudRepository<T, ID> {
1616

1717
/**
1818
* @see CrudRepository#findById(Object)
1919
*/
2020
Optional<T> findById(ID id, EntityGraph entityGraph);
2121

2222
/**
23-
* @see CrudRepository#findAllById(Iterable)
23+
* @see CrudRepository#findAll()
2424
*/
25-
Iterable<T> findAllById(Iterable<ID> ids, EntityGraph entityGraph);
25+
Iterable<T> findAll(EntityGraph entityGraph);
2626

2727
/**
28-
* @see CrudRepository#findAll()
28+
* @see CrudRepository#findAllById(Iterable)
2929
*/
30-
Iterable<T> findAll(EntityGraph entityGraph);
30+
Iterable<T> findAllById(Iterable<ID> ids, EntityGraph entityGraph);
3131
}
Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
package com.cosium.spring.data.jpa.entity.graph.repository;
22

3+
import com.cosium.spring.data.jpa.entity.graph.domain2.EntityGraph;
4+
import java.util.List;
5+
import org.springframework.data.domain.Example;
6+
import org.springframework.data.domain.Sort;
37
import org.springframework.data.jpa.repository.JpaRepository;
48
import org.springframework.data.repository.NoRepositoryBean;
59

@@ -10,6 +14,20 @@
1014
*/
1115
@NoRepositoryBean
1216
public interface EntityGraphJpaRepository<T, ID>
13-
extends JpaRepository<T, ID>,
14-
EntityGraphPagingAndSortingRepository<T, ID>,
15-
EntityGraphQueryByExampleExecutor<T> {}
17+
extends EntityGraphListCrudRepository<T, ID>,
18+
EntityGraphListPagingAndSortingRepository<T, ID>,
19+
EntityGraphQueryByExampleExecutor<T>,
20+
JpaRepository<T, ID> {
21+
22+
/**
23+
* @see JpaRepository#findAll(Example)
24+
*/
25+
@Override
26+
<S extends T> List<S> findAll(Example<S> example, EntityGraph entityGraph);
27+
28+
/**
29+
* @see JpaRepository#findAll(Example, Sort)
30+
*/
31+
@Override
32+
<S extends T> List<S> findAll(Example<S> example, Sort sort, EntityGraph entityGraph);
33+
}

core/src/main/java/com/cosium/spring/data/jpa/entity/graph/repository/EntityGraphJpaSpecificationExecutor.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,15 @@ public interface EntityGraphJpaSpecificationExecutor<T> extends JpaSpecification
3333
*/
3434
Page<T> findAll(Specification<T> spec, Pageable pageable, EntityGraph entityGraph);
3535

36+
/**
37+
* @see JpaSpecificationExecutor#findAll(Specification, Specification, Pageable)
38+
*/
39+
Page<T> findAll(
40+
Specification<T> spec,
41+
Specification<T> countSpec,
42+
Pageable pageable,
43+
EntityGraph entityGraph);
44+
3645
/**
3746
* @see JpaSpecificationExecutor#findAll(Specification, Sort)
3847
*/
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.cosium.spring.data.jpa.entity.graph.repository;
2+
3+
import com.cosium.spring.data.jpa.entity.graph.domain2.EntityGraph;
4+
import java.util.List;
5+
import org.springframework.data.repository.ListCrudRepository;
6+
import org.springframework.data.repository.NoRepositoryBean;
7+
8+
/**
9+
* @author Réda Housni Alaoui
10+
*/
11+
@NoRepositoryBean
12+
public interface EntityGraphListCrudRepository<T, ID>
13+
extends EntityGraphCrudRepository<T, ID>, ListCrudRepository<T, ID> {
14+
15+
/**
16+
* @see ListCrudRepository#findAll()
17+
*/
18+
@Override
19+
List<T> findAll(EntityGraph entityGraph);
20+
21+
/**
22+
* @see ListCrudRepository#findAllById(Iterable)
23+
*/
24+
@Override
25+
List<T> findAllById(Iterable<ID> ids, EntityGraph entityGraph);
26+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package com.cosium.spring.data.jpa.entity.graph.repository;
2+
3+
import com.cosium.spring.data.jpa.entity.graph.domain2.EntityGraph;
4+
import java.util.List;
5+
import org.springframework.data.domain.Sort;
6+
import org.springframework.data.repository.ListPagingAndSortingRepository;
7+
import org.springframework.data.repository.NoRepositoryBean;
8+
9+
/**
10+
* @author Réda Housni Alaoui
11+
*/
12+
@NoRepositoryBean
13+
public interface EntityGraphListPagingAndSortingRepository<T, ID>
14+
extends EntityGraphPagingAndSortingRepository<T, ID>, ListPagingAndSortingRepository<T, ID> {
15+
16+
/**
17+
* @see ListPagingAndSortingRepository#findAll(Sort)
18+
*/
19+
List<T> findAll(Sort sort, EntityGraph entityGraph);
20+
}

core/src/main/java/com/cosium/spring/data/jpa/entity/graph/repository/EntityGraphPagingAndSortingRepository.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@
1414
*/
1515
@NoRepositoryBean
1616
public interface EntityGraphPagingAndSortingRepository<T, ID>
17-
extends PagingAndSortingRepository<T, ID>, EntityGraphCrudRepository<T, ID> {
17+
extends PagingAndSortingRepository<T, ID>, EntityGraphRepository<T, ID> {
1818

1919
/**
20-
* @see PagingAndSortingRepository#findAll(Pageable)
20+
* @see PagingAndSortingRepository#findAll(Sort)
2121
*/
22-
Page<T> findAll(Pageable pageable, EntityGraph entityGraph);
22+
Iterable<T> findAll(Sort sort, EntityGraph entityGraph);
2323

2424
/**
25-
* @see PagingAndSortingRepository#findAll(Sort)
25+
* @see PagingAndSortingRepository#findAll(Pageable)
2626
*/
27-
Iterable<T> findAll(Sort sort, EntityGraph entityGraph);
27+
Page<T> findAll(Pageable pageable, EntityGraph entityGraph);
2828
}

core/src/main/java/com/cosium/spring/data/jpa/entity/graph/repository/EntityGraphQueryByExampleExecutor.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package com.cosium.spring.data.jpa.entity.graph.repository;
22

33
import com.cosium.spring.data.jpa.entity.graph.domain2.EntityGraph;
4-
import java.util.List;
54
import java.util.Optional;
65
import org.springframework.data.domain.Example;
76
import org.springframework.data.domain.Page;
@@ -19,22 +18,22 @@
1918
public interface EntityGraphQueryByExampleExecutor<T> extends QueryByExampleExecutor<T> {
2019

2120
/**
22-
* @see QueryByExampleExecutor#findAll(Example, Pageable)
21+
* @see QueryByExampleExecutor#findOne(Example)
2322
*/
24-
<S extends T> Page<S> findAll(Example<S> example, Pageable pageable, EntityGraph entityGraph);
23+
<S extends T> Optional<S> findOne(Example<S> example, EntityGraph entityGraph);
2524

2625
/**
27-
* @see QueryByExampleExecutor#findOne(Example)
26+
* @see QueryByExampleExecutor#findAll(Example)
2827
*/
29-
<S extends T> Optional<S> findOne(Example<S> example, EntityGraph entityGraph);
28+
<S extends T> Iterable<S> findAll(Example<S> example, EntityGraph entityGraph);
3029

3130
/**
3231
* @see QueryByExampleExecutor#findAll(Example, Sort)
3332
*/
34-
<S extends T> List<S> findAll(Example<S> example, Sort sort, EntityGraph entityGraph);
33+
<S extends T> Iterable<S> findAll(Example<S> example, Sort sort, EntityGraph entityGraph);
3534

3635
/**
37-
* @see QueryByExampleExecutor#findAll(Example)
36+
* @see QueryByExampleExecutor#findAll(Example, Pageable)
3837
*/
39-
<S extends T> List<S> findAll(Example<S> example, EntityGraph entityGraph);
38+
<S extends T> Page<S> findAll(Example<S> example, Pageable pageable, EntityGraph entityGraph);
4039
}

core/src/main/java/com/cosium/spring/data/jpa/entity/graph/repository/EntityGraphQuerydslPredicateExecutor.java

Lines changed: 6 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -19,69 +19,32 @@
1919
public interface EntityGraphQuerydslPredicateExecutor<T> extends QuerydslPredicateExecutor<T> {
2020

2121
/**
22-
* Returns a single entity matching the given {@link Predicate} or {@literal null} if none was
23-
* found.
24-
*
25-
* @param predicate can be {@literal null}.
26-
* @param entityGraph can be {@literal null}.
27-
* @return a single entity matching the given {@link Predicate} or {@literal null} if none was
28-
* found.
29-
* @throws org.springframework.dao.IncorrectResultSizeDataAccessException if the predicate yields
30-
* more than one result.
22+
* @see QuerydslPredicateExecutor#findOne(Predicate)
3123
*/
3224
Optional<T> findOne(Predicate predicate, EntityGraph entityGraph);
3325

3426
/**
35-
* Returns all entities matching the given {@link Predicate}. In case no match could be found an
36-
* empty {@link Iterable} is returned.
37-
*
38-
* @param predicate can be {@literal null}.
39-
* @param entityGraph can be {@literal null}.
40-
* @return all entities matching the given {@link Predicate}.
27+
* @see QuerydslPredicateExecutor#findAll(Predicate)
4128
*/
4229
Iterable<T> findAll(Predicate predicate, EntityGraph entityGraph);
4330

4431
/**
45-
* Returns all entities matching the given {@link Predicate} applying the given {@link Sort}. In
46-
* case no match could be found an empty {@link Iterable} is returned.
47-
*
48-
* @param predicate can be {@literal null}.
49-
* @param sort the {@link Sort} specification to sort the results by, must not be {@literal null}.
50-
* @param entityGraph can be {@literal null}.
51-
* @return all entities matching the given {@link Predicate}.
52-
* @since 1.10
32+
* @see QuerydslPredicateExecutor#findAll(Predicate, Sort)
5333
*/
5434
Iterable<T> findAll(Predicate predicate, Sort sort, EntityGraph entityGraph);
5535

5636
/**
57-
* Returns all entities matching the given {@link Predicate} applying the given {@link
58-
* OrderSpecifier}s. In case no match could be found an empty {@link Iterable} is returned.
59-
*
60-
* @param predicate can be {@literal null}.
61-
* @param entityGraph can be {@literal null}.
62-
* @param orders the {@link OrderSpecifier}s to sort the results by
63-
* @return all entities matching the given {@link Predicate} applying the given {@link
64-
* OrderSpecifier}s.
37+
* @see QuerydslPredicateExecutor#findAll(Predicate, OrderSpecifier[])
6538
*/
6639
Iterable<T> findAll(Predicate predicate, EntityGraph entityGraph, OrderSpecifier<?>... orders);
6740

6841
/**
69-
* Returns all entities ordered by the given {@link OrderSpecifier}s.
70-
*
71-
* @param orders the {@link OrderSpecifier}s to sort the results by.
72-
* @param entityGraph can be {@literal null}.
73-
* @return all entities ordered by the given {@link OrderSpecifier}s.
42+
* @see QuerydslPredicateExecutor#findAll(OrderSpecifier[])
7443
*/
7544
Iterable<T> findAll(EntityGraph entityGraph, OrderSpecifier<?>... orders);
7645

7746
/**
78-
* Returns a {@link Page} of entities matching the given {@link Predicate}. In case no match could
79-
* be found, an empty {@link Page} is returned.
80-
*
81-
* @param predicate can be {@literal null}.
82-
* @param pageable can be {@literal null}.
83-
* @param entityGraph can be {@literal null}.
84-
* @return a {@link Page} of entities matching the given {@link Predicate}.
47+
* @see QuerydslPredicateExecutor#findAll(Predicate, Pageable)
8548
*/
8649
Page<T> findAll(Predicate predicate, Pageable pageable, EntityGraph entityGraph);
8750
}

core/src/main/java/com/cosium/spring/data/jpa/entity/graph/repository/support/EntityGraphSimpleJpaRepository.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,15 @@ public Page<T> findAll(Specification<T> spec, Pageable pageable, EntityGraph ent
4848
return findAll(spec, pageable);
4949
}
5050

51+
@Override
52+
public Page<T> findAll(
53+
Specification<T> spec,
54+
Specification<T> countSpec,
55+
Pageable pageable,
56+
EntityGraph entityGraph) {
57+
return findAll(spec, countSpec, pageable);
58+
}
59+
5160
@Override
5261
public List<T> findAll(Specification<T> spec, Sort sort, EntityGraph entityGraph) {
5362
return findAll(spec, sort);
@@ -90,12 +99,12 @@ public List<T> findAllById(Iterable<ID> ids, EntityGraph entityGraph) {
9099
}
91100

92101
@Override
93-
public Iterable<T> findAll(Sort sort, EntityGraph entityGraph) {
102+
public List<T> findAll(Sort sort, EntityGraph entityGraph) {
94103
return findAll(sort);
95104
}
96105

97106
@Override
98-
public Iterable<T> findAll(EntityGraph entityGraph) {
107+
public List<T> findAll(EntityGraph entityGraph) {
99108
return findAll();
100109
}
101110
}

core/src/test/java/com/cosium/spring/data/jpa/entity/graph/repository/EntityGraphJpaRepositoryTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ public interface ProductRepository
355355

356356
@org.springframework.data.jpa.repository.EntityGraph(attributePaths = "brand")
357357
@Override
358-
Iterable<Product> findAll(EntityGraph entityGraph);
358+
List<Product> findAll(EntityGraph entityGraph);
359359

360360
@org.springframework.data.jpa.repository.EntityGraph(attributePaths = "brand")
361361
List<Product> findByName(String name, EntityGraph entityGraph);

0 commit comments

Comments
 (0)