1   package org.wcb.model.dao.impl;
2   
3   import org.wcb.exception.DAOException;
4   import org.wcb.exception.InfrastructureException;
5   import org.wcb.model.dao.IAircraftTypeDAO;
6   import org.wcb.model.vo.hibernate.AircraftTypeBO;
7   import org.springframework.dao.DataAccessException;
8   
9   import java.util.List;
10  
11  /**
12   * <small>
13   * Copyright (c)  2006  wbogaardt.
14   * Permission is granted to copy, distribute and/or modify this document
15   * under the terms of the GNU Free Documentation License, Version 1.2
16   * or any later version published by the Free Software Foundation;
17   * with no Invariant Sections, no Front-Cover Texts, and no Back-Cover
18   * Texts.  A copy of the license is included in the section entitled "GNU
19   * Free Documentation License".
20   * <p/>
21   * $File:  $ <br>
22   * $Change:  $ submitted by $Author: wbogaardt $ at $DateTime: Mar 24, 2006 10:01:39 AM $ <br>
23   * </small>
24   *
25   * @author wbogaardt
26   * @version 1
27   *          Date: Mar 24, 2006
28   *          Time: 10:01:39 AM
29   */
30  
31  public class AircraftTypeDAO extends AbstractHibernateDAO implements IAircraftTypeDAO {
32  
33      public AircraftTypeBO findAircraftType(Integer id) throws InfrastructureException {
34      	try {
35      		return (AircraftTypeBO) getObjectsBy(AircraftTypeBO.class, "id", id).get(0);
36      	} catch (DAOException daoe) {
37      		throw new InfrastructureException(daoe);
38      	} catch (IndexOutOfBoundsException ioobe) {
39              throw new InfrastructureException("No entry found");
40          }
41      }
42  
43      public List<AircraftTypeBO> findAll() throws InfrastructureException {
44         try {
45              boolean b = getHibernateTemplate().isCacheQueries();
46              getHibernateTemplate().setCacheQueries(true);
47              List<AircraftTypeBO> objects;
48              objects = getHibernateTemplate().loadAll(AircraftTypeBO.class);
49              getHibernateTemplate().setCacheQueries(b);
50              return objects;
51          } catch (DataAccessException e) {
52              throw new InfrastructureException(e);
53          }
54      }
55  }