source: ether_ndacc_bis/persistence/implementation/com/ether/dao/instrument/InstrumentDAOImpl.java @ 827

Last change on this file since 827 was 827, checked in by npipsl, 9 years ago

Changement Jussieu vers Polytechnique

File size: 1.5 KB
Line 
1package com.ether.dao.instrument;
2
3import java.util.List;
4
5import org.hibernate.criterion.DetachedCriteria;
6import org.hibernate.criterion.Projections;
7import org.hibernate.criterion.Restrictions;
8import org.jetbrains.annotations.NotNull;
9import org.jetbrains.annotations.Nullable;
10
11import com.ether.PersistenceException;
12import com.ether.dao.DomainAccessObjectImpl;
13import com.ether.instrument.Instrument;
14import com.ether.instrument.InstrumentType;
15
16/**
17 * @author vmipsl
18 * @date 24 jan 2011
19 */
20public class InstrumentDAOImpl extends DomainAccessObjectImpl<Instrument, Long>
21        implements InstrumentDAO
22{
23    protected InstrumentDAOImpl() {
24        super(Instrument.class);
25    }
26
27    public Integer getNbInstruments() throws PersistenceException
28    {
29        final DetachedCriteria criteria = DetachedCriteria.forClass(Instrument.class)
30                .setProjection(Projections.property("id"));
31
32        return count(criteria);
33    }
34
35    @Nullable
36    public List<Instrument> getInstrumentsByStationId( @NotNull final Long stationId ) throws PersistenceException
37    {
38        final DetachedCriteria criteria = DetachedCriteria.forClass(Instrument.class)
39                .add(Restrictions.eq("station.id", stationId));
40
41        return selectAllByCriteria(Instrument.class, criteria);
42    }
43
44    @Nullable
45    public List<Instrument> getInstrumentsByType( @NotNull final InstrumentType type ) throws PersistenceException
46    {
47        final DetachedCriteria criteria = DetachedCriteria.forClass(Instrument.class)
48                .add(Restrictions.eq("type", type));
49
50        return selectAllByCriteria(Instrument.class, criteria);
51    }
52}
Note: See TracBrowser for help on using the repository browser.