1 package ejava.projects.eleague.jpa;
2
3 import java.util.List;
4
5 import javax.persistence.EntityManager;
6
7 import ejava.projects.eleague.bo.Venue;
8 import ejava.projects.eleague.dao.ClubDAO;
9 import ejava.projects.eleague.dao.ClubDAOException;
10
11
12
13
14
15 public class JPAClubDAO implements ClubDAO {
16 private EntityManager em;
17
18
19
20
21
22 public void setEntityManager(EntityManager em) {
23 this.em = em;
24 }
25
26 @Override
27 public void createVenue(Venue venue) {
28 em.persist(venue);
29 }
30
31 @Override
32 public List<Venue> getVenues(int index, int count)
33 throws ClubDAOException {
34 return em.createQuery("select v from Venue v", Venue.class)
35 .setFirstResult(index)
36 .setMaxResults(count)
37 .getResultList();
38 }
39 }