Skip to content

Commit

Permalink
Polishing SimpleJpaRepository
Browse files Browse the repository at this point in the history
1. `TypedQuery.set*()` returns the same query instance
2. use `instanceof` instead of `isInstance()`
  • Loading branch information
quaff committed Jul 4, 2024
1 parent 018c833 commit 351a305
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ public void deleteAllByIdInBatch(Iterable<ID> ids) {
* Some JPA providers require {@code ids} to be a {@link Collection} so we must convert if it's not already.
*/

if (Collection.class.isInstance(ids)) {
if (ids instanceof Collection) {
query.setParameter("ids", ids);
} else {
Collection<ID> idsCollection = StreamSupport.stream(ids.spliterator(), false)
Expand Down Expand Up @@ -854,11 +854,13 @@ private <S> TypedQuery<S> applyRepositoryMethodMetadata(TypedQuery<S> query) {
}

LockModeType type = metadata.getLockModeType();
TypedQuery<S> toReturn = type == null ? query : query.setLockMode(type);
if (type != null) {
query.setLockMode(type);
}

applyQueryHints(toReturn);
applyQueryHints(query);

return toReturn;
return query;
}

private void applyQueryHints(Query query) {
Expand Down

0 comments on commit 351a305

Please sign in to comment.