View Javadoc

1   /***
2   Copyright (C) 2005 The Java Community
3   
4   This program is free software; you can redistribute it and/or modify  it under
5   the terms of the GNU General Public License as published by  the Free Software
6   Foundation; either version 2 of the License, or  (at your option) any later
7   version.
8   
9   This program is distributed in the hope that it will be useful,  but WITHOUT
10  ANY WARRANTY; without even the implied warranty of  MERCHANTABILITY or FITNESS
11  FOR A PARTICULAR PURPOSE. See the  GNU General Public License for more details.
12  
13  You should have received a copy of the GNU General Public License  along with
14  this program; if not, write to the Free Software  Foundation, Inc., 59 Temple
15  Place, Suite 330, Boston, MA 02111-1307 USA.
16  */
17  package org.bejug.javacareers.jobs.dao.hibernate;
18  
19  import org.bejug.javacareers.jobs.dao.RegionDao;
20  import org.bejug.javacareers.jobs.model.Region;
21  import org.springframework.dao.DataAccessException;
22  import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
23  
24  import java.util.List;
25  
26  /***
27   * Region DAO Hibernate DAO implementation.
28   * 
29   * @author Sven Schauwvliege (Last modified by $Author: stephan_janssen $)
30   * @version $Revision: 1.2 $ - $Date: 2005/10/11 08:45:51 $
31   */
32  public class RegionDaoHibernateImpl extends HibernateDaoSupport
33                                      implements RegionDao {
34  
35      /*** 
36       * {@inheritDoc}
37       */
38      public void store(Region region) throws DataAccessException {
39         
40          getHibernateTemplate().save(region);
41      }
42  
43      /*** 
44       * {@inheritDoc}
45       */
46      public List getCountries() throws DataAccessException {
47          return getHibernateTemplate().loadAll(Region.class);
48      }
49  
50      /*** 
51       * {@inheritDoc}
52       */
53      public void deleteRegion(Region region) throws DataAccessException {
54          getHibernateTemplate().delete( region); 
55  
56      }
57  
58      /*** 
59       * {@inheritDoc}
60       */
61      public void deleteRegion(Integer id) throws DataAccessException {
62          Region region = (Region)getHibernateTemplate().load(Region.class, id);
63          getHibernateTemplate().delete(region);
64      }
65  
66      /*** 
67       * {@inheritDoc}
68       */
69      public Region getRegion(Integer id) throws DataAccessException {
70          return (Region) getHibernateTemplate().load(Region.class, id);
71      }
72  
73      /***
74       * {@inheritDoc}
75       */
76      public Region getRegionByName(String region) {
77          List regions = getHibernateTemplate().findByNamedQueryAndNamedParam(
78                  "findRegionByName", "name", region);
79  
80          Region regio = null;
81          if (regions.size() != 0) {
82              regio = (Region) regions.get(0);
83          }
84  
85          return regio;
86      }
87  }
88  /*** 
89   * $Log: RegionDaoHibernateImpl.java,v $
90   * Revision 1.2  2005/10/11 08:45:51  stephan_janssen
91   * Reformat code.
92   *
93   * Revision 1.1  2005/08/26 07:58:30  ge0ffrey
94   * split up the sources in service, serviceimpl and webclient
95   *
96   * Revision 1.2  2005/08/10 14:21:02  bme_jcs
97   * organised imports
98   *
99   * Revision 1.1  2005/08/10 13:58:33  schauwvliege
100  * added RegioDao
101  *
102  * 
103  **/