Search⌘ K

Develop the Mock Service

Explore how to develop a mock service that performs create, read, update, and delete operations using an in-memory database following the Singleton pattern. Understand how these methods support managing entities in a concrete table inheritance structure within Java Spring applications.

add function

Let’s look at a simple add to the in-memory convention database which is based on the Singleton pattern implemented as an enum.

Java
public enum EstateInMemoryDB {
INSTANCE;
private static List<EstateDto> list = new ArrayList<EstateDto>();
private static Integer lastId = 0;
public Integer getId() {
return ++lastId;
}
public void add(EstateDto estateDto) {
estateDto.setId(getId());
list.add(estateDto);
}
}

Create operation

We will watch the mock service for the create ...