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
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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 }