You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: documentation/src/main/asciidoc/introduction/Introduction.adoc
+8-8Lines changed: 8 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -118,7 +118,7 @@ When in the slightest doubt, map a foreign key relationship using `@ManyToOne` w
118
118
119
119
.What sort of logic belongs in an entity?
120
120
****
121
-
There exists an extensive online literature which posits that there are _rich domain model_, where entities have methods implementing interesting business logic, and _anemic domain models_, where the entities are pure data holders, and that a developer should hold an opinion that one or the other of these sorts of domain model is "better".
121
+
There exists an extensive online literature which posits that there are _rich domain models_, where entities have methods implementing interesting business logic, and _anemic domain models_, where the entities are pure data holders, and that a developer should hold an opinion that one or the other of these sorts of domain model is "better".
122
122
123
123
We do not hold any such opinion, and if you ask us for one, we will most likely suddenly discover somewhere else we need to be.
124
124
@@ -134,8 +134,8 @@ One way to summarize this is:
134
134
135
135
> Entities do business logic; but they don't do orchestration.
136
136
137
-
So which code is responsible for orchestration of things like transaction management, query execution, or event publication?
138
-
Well, that's what we're about to discuss.
137
+
Later, we'll discuss various ways to <<managing-transactions,manage transactions>>, <<callbacks,send event notifications>>, and <<organizing-persistence,query the database>>.
138
+
Such code will always be external to the entity itself.
139
139
****
140
140
141
141
The second part of the code is much trickier to get right. This code must:
@@ -151,11 +151,11 @@ The second part of the code is much trickier to get right. This code must:
151
151
Responsibility for transaction and session management, and for recovery from certain kinds of failure, is best handled in some sort of framework code.
152
152
====
153
153
154
-
[TIP]
155
-
====
156
-
A great way to handle CDI event publication is via a <<callbacks,JPA entity listener>>.
157
-
Whereas we would never want to inject a CDI https://jakarta.ee/specifications/cdi/3.0/apidocs/[event publisher] into an entity object, it's perfectly fine to inject them in an entity listener.
158
-
====
154
+
// [TIP]
155
+
// ====
156
+
// A great way to handle CDI event publication is via a <<callbacks,JPA entity listener>>.
157
+
// Whereas we would never want to inject a CDI https://jakarta.ee/specifications/cdi/3.0/apidocs/[event publisher] into an entity object, it's perfectly fine to inject them in an entity listener.
158
+
// ====
159
159
160
160
We're going to <<organizing-persistence,come back soon>> to the thorny question of how this persistence logic should be organized, and how it should fit into the rest of the system.
161
161
// First we want to make the ideas above concrete by seeing a simple example program that uses Hibernate in isolation.
0 commit comments