Referensapplikationens HandlingEventRepository kan persistera en förändring av Cargo utan att använda CargoRepository

3 views
Skip to first unread message

Tomas Johansson

unread,
Mar 14, 2010, 8:27:31 PM3/14/10
to DDD Sverige
Nedan är ett kodexempel som illustrerar hur man kan ändra en Cargo
utan att använda CargoRepository (men genom att endast använda
HandlingEventRepository) :

HandlingHistory handlingHistory =
handlingEventRepository.lookupHandlingHistoryOfCargo(new
TrackingId(" ... "));
HandlingEvent latestHandlingEvent =
handlingHistory.distinctEventsByCompletionTime().get(0);
Cargo cargo = latestHandlingEvent.cargo();

Location newDestination = locationRepository.find(new
UnLocode( ... ));

RouteSpecification currentRouteSpecification =
cargo.routeSpecification();
RouteSpecification newRouteSpecification = new RouteSpecification(
currentRouteSpecification.origin(),
newDestination,
currentRouteSpecification.arrivalDeadline()
);
cargo.specifyNewRoute(newRouteSpecification);

handlingEventRepository.store(latestHandlingEvent);

Det sistnämnda anropet ovan modifierar databasfältet
"cargo.spec_destination_id" i den aktuella hibernate implementationen
som är konfigurerad enligt:
https://dddsample.svn.sourceforge.net/svnroot/dddsample/tags/dddsample-1.1.0/src/main/resources/se/citerus/dddsample/infrastructure/persistence/hibernate/

Är detta en känd bugg ?
Eller kanske ni inte betraktar det som en bugg att man kan persistera
data inom ett aggregat via ett annat repository än det som tillhör
aggregatet ?
(vilket f.ö. diskuerades i följande tråd i den internationella
gruppen:
http://tech.groups.yahoo.com/group/domaindrivendesign/message/8614
)

/ Tomas

Reply all
Reply to author
Forward
0 new messages