View Javadoc

1   package se.citerus.dddsample.infrastructure.persistence.hibernate;
2   
3   import org.springframework.stereotype.Repository;
4   import se.citerus.dddsample.domain.model.cargo.TrackingId;
5   import se.citerus.dddsample.domain.model.handling.HandlingEvent;
6   import se.citerus.dddsample.domain.model.handling.HandlingEventRepository;
7   import se.citerus.dddsample.domain.model.handling.HandlingHistory;
8   
9   /**
10   * Hibernate implementation of HandlingEventRepository.
11   *
12   */
13  @Repository
14  public class HandlingEventRepositoryHibernate extends HibernateRepository implements HandlingEventRepository {
15  
16    @Override
17    public void store(final HandlingEvent event) {
18      getSession().save(event);
19    }
20  
21    @Override
22    public HandlingHistory lookupHandlingHistoryOfCargo(final TrackingId trackingId) {
23      return new HandlingHistory(getSession().createQuery(
24              "from HandlingEvent where cargo.trackingId = :tid").
25              setParameter("tid", trackingId).
26              list()
27      );
28    }
29  
30  }