1 package se.citerus.dddsample.infrastructure.persistence.hibernate;
2
3 import org.springframework.stereotype.Repository;
4 import se.citerus.dddsample.domain.model.location.Location;
5 import se.citerus.dddsample.domain.model.location.LocationRepository;
6 import se.citerus.dddsample.domain.model.location.UnLocode;
7
8 import java.util.List;
9
10 @Repository
11 public final class LocationRepositoryHibernate extends HibernateRepository implements LocationRepository {
12
13 public Location find(final UnLocode unLocode) {
14 return (Location) getSession().
15 createQuery("from Location where unLocode = ?").
16 setParameter(0, unLocode).
17 uniqueResult();
18 }
19
20 public List<Location> findAll() {
21 return getSession().createQuery("from Location").list();
22 }
23
24 }