Skip to content

Commit 9828c19

Browse files
committed
DATAJPA-218 - Use true is true predicate if probe yields to empty criteria.
1 parent 7b24496 commit 9828c19

File tree

8 files changed

+56
-69
lines changed

8 files changed

+56
-69
lines changed

src/main/java/org/springframework/data/jpa/convert/QueryByExamplePredicateBuilder.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public static <T> Predicate getPredicate(Root<T> root, CriteriaBuilder cb, Examp
8282
new PathNode("root", null, example.getProbe()));
8383

8484
if (predicates.isEmpty()) {
85-
return cb.isTrue(cb.literal(false));
85+
return cb.isTrue(cb.literal(true));
8686
}
8787

8888
if (predicates.size() == 1) {

src/main/java/org/springframework/data/jpa/provider/PersistenceProvider.java

+5-9
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
* @author Oliver Gierke
5353
* @author Thomas Darimont
5454
*/
55-
public enum PersistenceProvider implements QueryExtractor, ProxyIdAccessor {
55+
public enum PersistenceProvider implements QueryExtractor,ProxyIdAccessor {
5656

5757
/**
5858
* Hibernate persistence provider.
@@ -117,14 +117,13 @@ public <T> Collection<T> potentiallyConvertEmptyCollection(Collection<T> collect
117117
public CloseableIterator<Object> executeQueryWithResultStream(Query jpaQuery) {
118118
return new HibernateScrollableResultsIterator<Object>(jpaQuery);
119119
}
120-
121120
},
122121

123122
/**
124123
* EclipseLink persistence provider.
125124
*/
126-
ECLIPSELINK(Collections.singleton(ECLIPSELINK_ENTITY_MANAGER_INTERFACE), Collections
127-
.singleton(ECLIPSELINK_JPA_METAMODEL_TYPE)) {
125+
ECLIPSELINK(Collections.singleton(ECLIPSELINK_ENTITY_MANAGER_INTERFACE),
126+
Collections.singleton(ECLIPSELINK_JPA_METAMODEL_TYPE)) {
128127

129128
public String extractQueryString(Query query) {
130129
return ((JpaQuery<?>) query).getDatabaseQuery().getJPQLString();
@@ -164,7 +163,6 @@ public <T> Collection<T> potentiallyConvertEmptyCollection(Collection<T> collect
164163
public CloseableIterator<Object> executeQueryWithResultStream(Query jpaQuery) {
165164
return new EclipseLinkScrollableResultsIterator<Object>(jpaQuery);
166165
}
167-
168166
},
169167

170168
/**
@@ -203,7 +201,6 @@ public Object getIdentifierFrom(Object entity) {
203201
public CloseableIterator<Object> executeQueryWithResultStream(Query jpaQuery) {
204202
return new OpenJpaResultStreamingIterator<Object>(jpaQuery);
205203
}
206-
207204
},
208205

209206
/**
@@ -246,7 +243,6 @@ public boolean shouldUseAccessorFor(Object entity) {
246243
public Object getIdentifierFrom(Object entity) {
247244
return null;
248245
}
249-
250246
};
251247

252248
/**
@@ -388,8 +384,8 @@ public <T> Collection<T> potentiallyConvertEmptyCollection(Collection<T> collect
388384
}
389385

390386
public CloseableIterator<Object> executeQueryWithResultStream(Query jpaQuery) {
391-
throw new UnsupportedOperationException("Streaming results is not implement for this PersistenceProvider: "
392-
+ name());
387+
throw new UnsupportedOperationException(
388+
"Streaming results is not implement for this PersistenceProvider: " + name());
393389
}
394390

395391
/**

src/main/java/org/springframework/data/jpa/repository/JpaRepository.java

+3-7
Original file line numberDiff line numberDiff line change
@@ -41,28 +41,24 @@ public interface JpaRepository<T, ID extends Serializable>
4141
* (non-Javadoc)
4242
* @see org.springframework.data.repository.CrudRepository#findAll()
4343
*/
44-
@Override
4544
List<T> findAll();
4645

4746
/*
4847
* (non-Javadoc)
4948
* @see org.springframework.data.repository.PagingAndSortingRepository#findAll(org.springframework.data.domain.Sort)
5049
*/
51-
@Override
5250
List<T> findAll(Sort sort);
5351

5452
/*
5553
* (non-Javadoc)
5654
* @see org.springframework.data.repository.CrudRepository#findAll(java.lang.Iterable)
5755
*/
58-
@Override
5956
List<T> findAll(Iterable<ID> ids);
6057

6158
/*
6259
* (non-Javadoc)
6360
* @see org.springframework.data.repository.CrudRepository#save(java.lang.Iterable)
6461
*/
65-
@Override
6662
<S extends T> List<S> save(Iterable<S> entities);
6763

6864
/**
@@ -72,7 +68,7 @@ public interface JpaRepository<T, ID extends Serializable>
7268

7369
/**
7470
* Saves an entity and flushes changes instantly.
75-
*
71+
*
7672
* @param entity
7773
* @return the saved entity
7874
*/
@@ -81,7 +77,7 @@ public interface JpaRepository<T, ID extends Serializable>
8177
/**
8278
* Deletes the given entities in a batch which means it will create a single {@link Query}. Assume that we will clear
8379
* the {@link javax.persistence.EntityManager} after the call.
84-
*
80+
*
8581
* @param entities
8682
*/
8783
void deleteInBatch(Iterable<T> entities);
@@ -93,7 +89,7 @@ public interface JpaRepository<T, ID extends Serializable>
9389

9490
/**
9591
* Returns a reference to the entity with the given identifier.
96-
*
92+
*
9793
* @param id must not be {@literal null}.
9894
* @return a reference to the entity with the given identifier.
9995
* @see EntityManager#getReference(Class, Object)

src/main/java/org/springframework/data/jpa/repository/query/AbstractJpaQuery.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,8 @@ private Query applyEntityGraphConfiguration(Query query, JpaQueryMethod method)
189189
Assert.notNull(query, "Query must not be null!");
190190
Assert.notNull(method, "JpaQueryMethod must not be null!");
191191

192-
Map<String, Object> hints = Jpa21Utils.tryGetFetchGraphHints(em, method.getEntityGraph(), getQueryMethod()
193-
.getEntityInformation().getJavaType());
192+
Map<String, Object> hints = Jpa21Utils.tryGetFetchGraphHints(em, method.getEntityGraph(),
193+
getQueryMethod().getEntityInformation().getJavaType());
194194

195195
for (Map.Entry<String, Object> hint : hints.entrySet()) {
196196
query.setHint(hint.getKey(), hint.getValue());

0 commit comments

Comments
 (0)