|
|
@@ -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
|
}
|