Thanks to visit codestin.com
Credit goes to github.com

Skip to content

angelicamarttins/entity-dto-converter

Repository files navigation

Entity to DTO Converter

This project is designed to explore and test different approaches for converting Entity objects into DTOs and vice versa. It demonstrates several methods for achieving this goal in a Spring Boot application.

Implemented Approaches

The following methods for entity-to-DTO conversion are implemented:

  • Constructor: Directly using constructors in DTO classes.
  • Static Method: Utilizing static factory methods for conversion.
  • @Builder (Lombok): Leveraging Lombok's @Builder annotation for building DTOs.
  • Manual Mapper: Writing custom mapper classes for conversion.
  • MapStruct: Using the MapStruct library for automatic mapping.
  • Spring Data JPA Projection: Utilizing JPA projections to create DTOs directly from queries.

Project Details

  • Java Version: Java 23
  • Frameworks: Spring Boot 3, JUnit 5
  • API Documentation: Swagger UI

How to Run

  1. Clone the repository:
git clone https://github.com/angelicamarttins/entity-dto-converter
cd entity-dto-converter
  1. Start the application:
./gradlew bootRun
  1. Open your browser and navigate to:
http://localhost:8080/swagger-ui/index.html
  1. Explore the endpoints:
  • Select an endpoint;
  • Click on Try it out;
  • Modify the request payload if needed;
  • Click Execute to see the response.

Request example in Swagger IU

https://github.com/melix/jmh-gradle-plugin https://github.com/artyushov/idea-jmh-plugin https://github.com/openjdk/jmh

About

Project to test different ways to converter Entity into DTO

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages