Skip to content

Commit

Permalink
#876 - upgrade to Java 21
Browse files Browse the repository at this point in the history
  • Loading branch information
rajadilipkolli committed Nov 4, 2023
1 parent d03409e commit b9c5c8a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ jobs:
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis

- name: Set up JDK 17
- name: Set up JDK 21
uses: actions/[email protected]
with:
java-version: 17
distribution: "zulu"
java-version: 21
distribution: "microsoft"
cache: "maven"

- name: Grant execute permission for mvnw
Expand Down
4 changes: 2 additions & 2 deletions graphql/boot-graphql-webmvc/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.2.0-M3</version>
<version>3.2.0-RC2</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<groupId>com.example.graphql</groupId>
Expand All @@ -19,7 +19,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

<java.version>17</java.version>
<java.version>21</java.version>
<springdoc-openapi.version>2.2.0</springdoc-openapi.version>
<org.mapstruct.extensions.spring.version>1.1.0</org.mapstruct.extensions.spring.version>
<org.mapstruct.version>1.5.5.Final</org.mapstruct.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
@Transactional(readOnly = true)
@RequiredArgsConstructor
@Loggable
public class PostCommentService {
Expand All @@ -30,7 +30,6 @@ public class PostCommentService {
private final PostCommentEntityToResponseMapper postCommentEntityToResponseMapper;
private final PostCommentRequestToEntityMapper postCommentRequestToEntityMapper;

@Transactional(readOnly = true)
public List<PostCommentResponse> findAllPostComments() {
List<CompletableFuture<PostCommentResponse>> completableFutureList =
postCommentRepository.findAll().stream()
Expand All @@ -44,34 +43,36 @@ public List<PostCommentResponse> findAllPostComments() {
return completableFutureList.stream().map(CompletableFuture::join).toList();
}

@Transactional(readOnly = true)
public Optional<PostCommentResponse> findPostCommentById(Long id) {
return findCommentById(id).map(postCommentEntityToResponseMapper::convert);
return this.postCommentRepository
.findById(id)
.map(postCommentEntityToResponseMapper::convert);
}

@Transactional(readOnly = true)
public Optional<PostCommentEntity> findCommentById(Long commentId) {
return this.postCommentRepository.findById(commentId);
}

@Transactional
public PostCommentResponse addCommentToPost(PostCommentRequest postCommentRequest) {
PostCommentEntity postCommentEntity =
postCommentRequestToEntityMapper.covert(postCommentRequest, postRepository);
return saveAndConvert(postCommentEntity);
}

@Transactional
public void deletePostCommentById(Long id) {
postCommentRepository.deleteById(id);
}

@Transactional(readOnly = true)
public Map<Long, List<PostCommentResponse>> getCommentsByPostIdIn(List<Long> postIds) {
return this.postCommentRepository.findByPostEntity_IdIn(postIds).stream()
.map(postCommentEntityToResponseMapper::convert)
.filter(Objects::nonNull)
.collect(Collectors.groupingBy(PostCommentResponse::postId));
}

@Transactional
public PostCommentResponse updatePostComment(
PostCommentEntity postCommentEntity, PostCommentRequest postCommentRequest) {
postCommentEntityToResponseMapper.updatePostCommentEntity(
Expand Down

0 comments on commit b9c5c8a

Please sign in to comment.