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