User-Friendly API Publishing and Testing With Retrofit

Any web service needs to export their public API if consumers want to make the best use of that service. A developer-friendly approach to do so if you work in the Java ecosystem is to package DTOs and endpoint interfaces in an API jar file and use the Retrofit framework to create type-safe clients for integration testing. This article discusses a complete example.

If you’ve worked in enterprise Java projects you will remember good old Web Services Description Language, the XML based format for describing network services by IBM and Microsoft. Maybe you still work with it? WSDL and its twin XML Schema are among those W3C standards that seasoned developers love to hate. Its specification files are not very human readable, let alone human writable. Fortunately you don't have to. They can be generated by your server endpoint and fed straight into a code generator to create transfer objects (DTOs) and service stubs.

DTO: Hipster or Deprecated?

Data Transfer Objects, known affectionately as DTOs, is the subject of a lot of discussions when we talk about the development of Java applications. DTOs were born in the Java world in EJB 2 for two purposes. 

First, to circumvent the EJB serialization problem; second, they implicitly define an assembly phase where all data that will be used for presentation is marshaled before actually going to the presentation layer. Since the EJB is no longer used on a large scale, can DTOs also be discarded? The purpose of this article is to talk a little bit about the usefulness of DTO and address this question.

How to Enrich DTOs With Virtual Properties Via Spring Projections

In JPA, as a rule of thumb, our queries (SQLs) must extract from the database only the needed data, meaning only the data that it is prone to be modified. When the fetched data is read-only (we don't plan to modify it), then we must strive to fetch it as DTOs instead of JPA entities. 

Starting from this statement, let's consider the following JPA trivial entity:

How to Delete Duplicates From an ArrayList of Type Pojo/DTO

Recently, in my current project, I got a requirement where I had to delete duplicates from anArrayList of type Pojo. I did a lot of research and found all the examples referring to an ArrayList of type String and where is easy to remove duplicates. However, the real world is always different!

Here is code to delete duplicates from an ArrayList based on two fields Material Type (matnrType) and Supplier (supplier).