Ver código fonte

Removed unused relation to HandlingEvent repository, added better explanation of query-and-load in cargoRepository.find() method

peter_backlund 18 anos atrás
pai
commit
7d5ef264c6

+ 5
- 8
dddsample/src/main/java/se/citerus/dddsample/application/persistence/CargoRepositoryHibernate.java Ver arquivo

@@ -5,7 +5,6 @@ import se.citerus.dddsample.domain.model.cargo.Cargo;
5 5
 import se.citerus.dddsample.domain.model.cargo.CargoRepository;
6 6
 import se.citerus.dddsample.domain.model.cargo.Itinerary;
7 7
 import se.citerus.dddsample.domain.model.cargo.TrackingId;
8
-import se.citerus.dddsample.domain.model.handling.HandlingEventRepository;
9 8
 
10 9
 import java.util.List;
11 10
 import java.util.UUID;
@@ -16,11 +15,12 @@ import java.util.UUID;
16 15
 @Repository
17 16
 public class CargoRepositoryHibernate extends HibernateRepository implements CargoRepository {
18 17
 
19
-  HandlingEventRepository handlingEventRepository;
20
-
21 18
   public Cargo find(TrackingId tid) {
22
-    // Query for id and then perform a standard load()
23
-    // to use metadata-defined query and lazy proxy access
19
+    // Query for id and then perform a standard load().
20
+    // This way we use the metadata-defined way of loading the aggregate
21
+    // in an efficient way (generally a complete aggregate at a time),
22
+    // and we can benefi from the identifier-keyed second level cache
23
+    // without havng to cache individual queries.
24 24
     Long id = (Long) getSession().
25 25
        createQuery("select id from Cargo where trackingId = :tid").
26 26
        setParameter("tid", tid).
@@ -59,7 +59,4 @@ public class CargoRepositoryHibernate extends HibernateRepository implements Car
59 59
     return getSession().createQuery("from Cargo").list();
60 60
   }
61 61
 
62
-  public void setHandlingEventRepository(HandlingEventRepository handlingEventRepository) {
63
-    this.handlingEventRepository = handlingEventRepository;
64
-  }
65 62
 }

+ 0
- 1
dddsample/src/main/resources/context-persistence-hibernate.xml Ver arquivo

@@ -28,7 +28,6 @@
28 28
   
29 29
   <bean id="cargoRepository" class="se.citerus.dddsample.application.persistence.CargoRepositoryHibernate">
30 30
     <property name="sessionFactory" ref="sessionFactory"/>
31
-    <property name="handlingEventRepository" ref="handlingEventRepository"/>
32 31
   </bean>
33 32
 
34 33
   <bean id="handlingEventRepository" class="se.citerus.dddsample.application.persistence.HandlingEventRepositoryHibernate">