response model
A type, often a record, that describes exactly the data an API accepts or returns, separate from database entities.
In more detail
Keeping wire models separate from persistence entities lets each change for its own reasons and stops internal fields leaking to clients. The service translates entities into response models before the controller returns them.
Example
record OrderView(String id, String status) { }Related terms
- record (Java) — A compact Java class for plain data, declared with its components in one line, for which the compiler generates the fields, accessors, equals, hashCode and toString.
- JPA entity — A class marked @Entity whose instances JPA stores as rows in a table, identified by a field marked @Id.
- wire format — The exact shape data takes when it travels between programs, such as the field names and types of a JSON body.
- service layer — The layer of an application that holds use cases and business rules, sitting between controllers and repositories.
Taught in
- Primitive And Reference Types — Modern Java: Virtual Threads & High-Throughput Services
- Records And Data Classes — Modern Java: Virtual Threads & High-Throughput Services
- Reading The Request — Modern Java: Virtual Threads & High-Throughput Services
- Implementing An OpenAPI Contract — Modern Java: Virtual Threads & High-Throughput Services
- Persistence With JPA And Hibernate — Modern Java: Virtual Threads & High-Throughput Services
- Spring Data Repositories — Modern Java: Virtual Threads & High-Throughput Services
- Tying It All Together — Modern Java: Virtual Threads & High-Throughput Services