liveBook · Manning

Domain model

As explained in Java Persistence with Spring Data and Hibernate epub

A domain model is an object-oriented representation of application-domain concepts, their state, and their relationships.

A domain model is an object-oriented view of the business concepts an application needs, their relationships, and potentially their attributes. It captures information relevant to the application rather than reproducing every detail of the real world. A conceptual model can be as informal as a mental picture or as explicit as a UML class diagram. section 3.1.2

To design a model, work with domain experts to identify the main entities, their interactions, and the rules needed to preserve data integrity. The entities should encapsulate state and behavior. Keep non-business concerns out of their implementation, since the model is a central component reused across application functionality. section 3.1.2 section 3.1.3 section 3.2

Online auction model

An auction model can associate Bid directly with Item when each item is auctioned only once. A User can have separate Address objects and multiple BillingDetails, whose subclasses represent billing strategies. Category can have child categories and at most one parent; each Item belongs to at least one Category. These classes describe the persistent part of the model, not necessarily the whole application. section 3.1.3

Figure 3.3 Persistent classes of the CaveatEmptor domain model and their relationships

Use the class diagram to follow the persistent auction classes and their relationships. section 3.1.3

In a Java implementation, business logic works with objects such as Item and Bid rather than directly with ResultSet rows and columns. Mapping metadata connects persistent classes and properties to database tables and columns; it can be expressed with annotations or XML. JPA providers such as Hibernate use mapping settings to load and store instances. section 1.1.3 section 3.0 section 5.0

The object and database models need not have the same granularity. A Java User can contain a finer-grained Address class even when address information is stored in separate columns of a USERS table. Inheritance and polymorphism can also shape the application model. A domain model is not mandatory: for a simple application, direct JDBC ResultSet access may be sufficient. section 1.2.1 section 1.1.3

How Java Persistence with Spring Data and Hibernate epub covers it

How deep it goes
Develops a conceptual model into persistent Java classes and mapping choices, including relationships, granularity, and separation of concerns.
Examples
Uses an online auction model with items, bids, users, addresses, billing strategies, and nested categories.
What you can do after
Evaluate and understand how to identify domain entities and represent their relationships and persistent state in Java.
How it connects
Connects domain modeling with object-relational mapping, data integrity, inheritance, and polymorphism.

Also explained in

Compare how 8 books explain domain model →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Java Persistence with Spring Data and Hibernate epub. The section links point to the parts of the book it draws on.