0% found this document useful (0 votes)
4 views1 page

SpringBoot Post API Assignment MultiRepository

The document outlines an assignment to develop a Post Management System using Spring Boot, focusing on creating a REST API with various components including an Entity class, multiple repositories, and a service interface. It specifies the structure of the Post entity, the required repositories for CRUD operations and queries, and the service methods for managing posts. Additionally, it details the REST controller endpoints for interacting with the API and lists the technologies to be used, including Spring Boot 3 and Spring Web.

Uploaded by

rachel.98hn.707
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views1 page

SpringBoot Post API Assignment MultiRepository

The document outlines an assignment to develop a Post Management System using Spring Boot, focusing on creating a REST API with various components including an Entity class, multiple repositories, and a service interface. It specifies the structure of the Post entity, the required repositories for CRUD operations and queries, and the service methods for managing posts. Additionally, it details the REST controller endpoints for interacting with the API and lists the technologies to be used, including Spring Boot 3 and Spring Web.

Uploaded by

rachel.98hn.707
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Spring Boot Assignment: Post Management System

Objectives:
- Create REST API
- Implement Service Interface and ServiceImpl
- Define Entity class
- Use Spring Data JPA with Hibernate
- Write queries using method names, JPQL, and native SQL
- Apply pagination using Page and Pageable
- Use auditing for automatic createdAt and updatedAt fields
- Organize multiple repositories for different query types

Assignment Requirements:
Develop a REST API for a Post Management System.

1. Entity: Post
- id (Long): primary key
- title (String): required
- content (String)
- author (String): required
- createdAt (LocalDateTime): auto-filled creation timestamp
- updatedAt (LocalDateTime): auto-filled last update timestamp
=> Use Spring Data JPA Auditing: @CreatedDate, @LastModifiedDate, and AuditorAware.

2. Repository
Create multiple repositories:
- PostRepository: contains basic CRUD and method name queries
- PostJqlRepository: contains JPQL queries using @Query
- PostNativeRepository: contains native SQL queries using @Query(nativeQuery = true)

Sample queries:
- Method Name: findByAuthorContainingIgnoreCase(String author, Pageable pageable)
- JPQL: searchByTitle(keyword)
- Native SQL: searchByContent(text)

3. Service
Create PostService interface and PostServiceImpl:
- getAllPosts(Pageable pageable)
- searchByAuthor(...)
- searchByTitle(...)
- searchByContentNative(...)
- getPostById(Long id)
- createPost(Post post)
- updatePost(Long id, Post post)
- deletePost(Long id)

4. REST Controller
Create PostRestController:
- GET /api/posts
- GET /api/posts/{id}
- POST /api/posts
- PUT /api/posts/{id}
- DELETE /api/posts/{id}
- GET /api/posts/search-author?author=...
- GET /api/posts/search-title?keyword=...
- GET /api/posts/search-content?text=...

Technologies:
- Spring Boot 3
- Spring Web

You might also like