Is There any Alternatives to DTO in Spring Boot 2.0 - spring-boot

I have a backend api and a frontend client (Angular App) consuming this api, I have to redefine many DTOs form Database Entities (almost 100). I wonder if there is an alternative to transform my entities with much more easier way than using Transformers.

You can use Jackson API to convert the Entity object into DTO or any POJO class objects. Please check below URL for the code example.
https://www.thetechnojournals.com/2019/10/entity-object-conversion-to-dto-object.html

Related

How to use Post Mapping to call GraphQL?

In traditional, we can use spring boot and different GraphQL component to build up a graphQL server, and then we use frontend framework (Angular etc) to call GraphQL endpoint.
But is there any way to use Spring MVC, in controller to call GraphQL relative class, to get the data, then put the data into model, and show in frontend jsp or template framework?
Hopefully I can get a github demo, or some document for reference

How will swagger work with spring boot if there is no rest controller, no request mapping annotation?

In my service there are only POJOs present but I don't need any controller to send them from any API, I just want to make a swagger documentation but they say there is no way to make swagger without the rest controller. Is there any way?
Generally swagger is used for documenting REST api but still you tweak it. Hope you are looking to generate schema/ dtos

Spring REST service with third party api as a datasource

I need to expose REST service which as a datasource gets data returned from third party api calls, instead of regular DB.
I'd like to have all the benefits of the Spring Data Rest, but I don't know what I really need as my dependency, since I'm not using JPA.
Basicaly, how my model (Entity?) should be implemented to have the functionalities (like, paging, sorting...).
What Spring framework dependencies should I choose.
Or possibly I'm overlooking something here and for such requirement is another path.
Thanks.

Where should Entity and DTO conversion happen for external calls?

I have a Spring REST interface and the controller is making the conversion from DTO to Business Entity objects. The Service layer operates on Business Entity objects. However, If my Business Layer wants to call external REST interfaces, where should that Business Entity to DTO conversion happen? At Business Layer? The DAO object using RestTemplate to make the call? Some other layer? The call sequence would current be like this:
business layer -> DAO -> RestTemplate -> RESTful service
Thanks! :)
Well, normally, in spring framework the conversion of a Model to DTO and backwards, is done by implementing org.springframework.core.convert.converter.Converter interface. Thus, getting a reusable converter which can be used either in Facade or DAO or Controller, depending on your needs. Business Layer should not be concerned about conversion. From my perspective, using converter in DAO is perfectly fine. :)

Expose #Service methods as Rest endpoints using spring-data-rest

I using spring-data-rest in conjunction to spring-data-jpa which exposes all my spring-data-jpa interfaces as REST resources in HAL JSON format.
I would like to expose my #Service methods in the same fashion. Is this possible? If not, what is the best way to implement an endpoint that may need to use more complex logic the JSON response?
I think you should take a look at this post:
Spring HATEOAS versus Spring Data Rest
Basically the answer says that if you want to expose a REST service which implies some logic more complex than CRUD, there's no other way but implementing the REST layer yourself.

Resources