Преглед на файлове

Improved comment on rationale behind the removed relation between DeliveryHistory and HandlingEvent.

peter_backlund преди 18 години
родител
ревизия
835276ab6b
променени са 1 файла, в които са добавени 9 реда и са изтрити 8 реда
  1. 9
    8
      dddsample/src/main/java/se/citerus/dddsample/repository/CargoRepositoryHibernate.java

+ 9
- 8
dddsample/src/main/java/se/citerus/dddsample/repository/CargoRepositoryHibernate.java Целия файл

@@ -12,17 +12,18 @@ public class CargoRepositoryHibernate extends HibernateRepository implements Car
12 12
 
13 13
   HandlingEventRepository handlingEventRepository;
14 14
 
15
-  public Cargo find(TrackingId trackingId) {
15
+  public Cargo find(TrackingId tid) {
16 16
     Cargo cargo = (Cargo) getSession().
17
-            createQuery("from Cargo where trackingId = ?").
18
-            setParameter(0, trackingId).
17
+            createQuery("from Cargo where trackingId = :tid").
18
+            setParameter("tid", tid).
19 19
             uniqueResult();
20
-    /*
20
+    /*  There's no OR-mapped relation between the cargo delivery history and its handling events
21
+        because the handling events are in a different aggregate.
22
+
21 23
         If this extra database call were a problem, you might want to use a different model.
22
-        For example, calculate the effect/status of the cargo and store it separate from the
23
-        handling events.
24
-     */
25
-    cargo.deliveryHistory().addAllEvents(handlingEventRepository.findEventsForCargo(trackingId));
24
+        For example, you could calculate the effect/status of the cargo and store it separate from the
25
+        handling events. */
26
+    cargo.deliveryHistory().addAllEvents(handlingEventRepository.findEventsForCargo(tid));
26 27
     return cargo;
27 28
   }
28 29