Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa-parent</artifactId>
<version>4.1.0-SNAPSHOT</version>
<version>4.1.0-4131-SNAPSHOT</version>
<packaging>pom</packaging>

<name>Spring Data JPA Parent</name>
Expand Down
4 changes: 2 additions & 2 deletions spring-data-envers/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@

<groupId>org.springframework.data</groupId>
<artifactId>spring-data-envers</artifactId>
<version>4.1.0-SNAPSHOT</version>
<version>4.1.0-4131-SNAPSHOT</version>

<parent>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa-parent</artifactId>
<version>4.1.0-SNAPSHOT</version>
<version>4.1.0-4131-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion spring-data-jpa-distribution/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<parent>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa-parent</artifactId>
<version>4.1.0-SNAPSHOT</version>
<version>4.1.0-4131-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
4 changes: 2 additions & 2 deletions spring-data-jpa/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
<version>4.1.0-SNAPSHOT</version>
<version>4.1.0-4131-SNAPSHOT</version>

<name>Spring Data JPA</name>
<description>Spring Data module for JPA repositories.</description>
Expand All @@ -16,7 +16,7 @@
<parent>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa-parent</artifactId>
<version>4.1.0-SNAPSHOT</version>
<version>4.1.0-4131-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ public SimpleJpaRepository(Class<T> domainClass, EntityManager entityManager) {
* Configures a custom {@link CrudMethodMetadata} to be used to detect {@link LockModeType}s and query hints to be
* applied to queries.
*
* @param metadata
* @param metadata custom {@link CrudMethodMetadata} to be used, can be {@literal null}.
*/
@Override
public void setRepositoryMethodMetadata(CrudMethodMetadata metadata) {
Expand Down Expand Up @@ -203,7 +203,6 @@ public void deleteById(ID id) {

@Override
@Transactional
@SuppressWarnings("unchecked")
public void delete(T entity) {

Assert.notNull(entity, ENTITY_MUST_NOT_BE_NULL);
Expand Down Expand Up @@ -334,13 +333,13 @@ public Optional<T> findById(ID id) {
Class<T> domainType = getDomainClass();

if (metadata == null) {
return Optional.ofNullable(entityManager.find(domainType, id));
return Optional.of(entityManager.find(domainType, id));
}

LockModeType type = metadata.getLockModeType();
Map<String, Object> hints = getHints();

return Optional.ofNullable(
return Optional.of(
type == null ? entityManager.find(domainType, id, hints) : entityManager.find(domainType, id, type, hints));
}

Expand Down Expand Up @@ -458,7 +457,7 @@ public Page<T> findAll(Pageable pageable) {

@Override
public Optional<T> findOne(Specification<T> spec) {
return Optional.ofNullable(getQuery(spec, Sort.unsorted()).setMaxResults(2).getSingleResultOrNull());
return Optional.of(getQuery(spec, Sort.unsorted()).setMaxResults(2).getSingleResultOrNull());
}

@Override
Expand All @@ -474,6 +473,8 @@ public Page<T> findAll(Specification<T> spec, Pageable pageable) {
@Override
public Page<T> findAll(@Nullable Specification<T> spec, @Nullable Specification<T> countSpec, Pageable pageable) {

spec = spec == null ? Specification.unrestricted() : spec;

TypedQuery<T> query = getQuery(spec, pageable);
return pageable.isUnpaged() ? new PageImpl<>(query.getResultList())
: readPage(query, getDomainClass(), pageable, countSpec);
Expand Down Expand Up @@ -752,7 +753,7 @@ protected <S extends T> Page<S> readPage(TypedQuery<S> query, Class<S> domainCla
* @param spec must not be {@literal null}.
* @param pageable must not be {@literal null}.
*/
protected TypedQuery<T> getQuery(@Nullable Specification<T> spec, Pageable pageable) {
protected TypedQuery<T> getQuery(Specification<T> spec, Pageable pageable) {
return getQuery(spec, getDomainClass(), pageable.getSort());
}

Expand Down Expand Up @@ -784,7 +785,7 @@ protected TypedQuery<T> getQuery(Specification<T> spec, Sort sort) {
* @param domainClass must not be {@literal null}.
* @param sort must not be {@literal null}.
*/
protected <S extends T> TypedQuery<S> getQuery(@Nullable Specification<S> spec, Class<S> domainClass, Sort sort) {
protected <S extends T> TypedQuery<S> getQuery(Specification<S> spec, Class<S> domainClass, Sort sort) {
return getQuery(ReturnedType.of(domainClass, domainClass, projectionFactory), spec, domainClass, sort,
Collections.emptySet(), null);
}
Expand Down
Loading