View Javadoc

1   /*
2    * $Id: SenderDaoImpl.java 19191 2010-08-25 21:05:23Z tcarlson $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
5    *
6    * The software in this package is published under the terms of the CPAL v1.0
7    * license, a copy of which has been included with this distribution in the
8    * LICENSE.txt file.
9    */
10  
11  package org.mule.example.geomail.dao.impl;
12  
13  import org.mule.example.geomail.dao.Sender;
14  import org.mule.example.geomail.dao.SenderDao;
15  
16  import java.util.Collection;
17  
18  import javax.persistence.EntityManager;
19  import javax.persistence.PersistenceContext;
20  
21  import org.springframework.transaction.annotation.Transactional;
22  
23  @Transactional
24  public class SenderDaoImpl implements SenderDao
25  {
26      private EntityManager entityManager;
27  
28      public Collection getSenders()
29      {
30          return getEntityManager().createQuery("SELECT sender FROM Sender sender").getResultList();
31      }
32  
33      public Sender getSender(String senderId)
34      {
35          return getEntityManager().find(Sender.class, senderId);
36      }
37  
38      public void addSender(Sender sender)
39      {
40          getEntityManager().persist(sender);
41      }
42  
43      public EntityManager getEntityManager()
44      {
45          return entityManager;
46      }
47  
48      @PersistenceContext
49      public void setEntityManager(EntityManager entityManager)
50      {
51          this.entityManager = entityManager;
52      }
53  }