2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
10 package eu
.etaxonomy
.cdm
.persistence
.dao
.hibernate
.common
;
12 import java
.util
.List
;
14 import org
.hibernate
.Query
;
15 import org
.springframework
.stereotype
.Repository
;
17 import eu
.etaxonomy
.cdm
.model
.common
.DefinedTermBase
;
18 import eu
.etaxonomy
.cdm
.model
.common
.TermVocabulary
;
19 import eu
.etaxonomy
.cdm
.persistence
.dao
.common
.ITermVocabularyDao
;
26 public class TermVocabularyDaoImpl
extends CdmEntityDaoBase
<TermVocabulary
<DefinedTermBase
>> implements
33 public TermVocabularyDaoImpl() {
34 super((Class
)TermVocabulary
.class);
37 public int countTerms(TermVocabulary termVocabulary
) {
38 Query query
= getSession().createQuery("select count(term) from TermVocabulary termVocabulary join termVocabulary.terms term where termVocabulary = :termVocabulary");
39 query
.setParameter("termVocabulary", termVocabulary
);
41 return ((Long
)query
.uniqueResult()).intValue();
44 public <T
extends DefinedTermBase
> List
<T
> getTerms(TermVocabulary
<T
> termVocabulary
, Integer pageSize
, Integer pageNumber
) {
45 Query query
= getSession().createQuery("select term from TermVocabulary termVocabulary join termVocabulary.terms term where termVocabulary = :termVocabulary");
46 query
.setParameter("termVocabulary", termVocabulary
);
48 if(pageSize
!= null) {
49 query
.setMaxResults(pageSize
);
50 if(pageNumber
!= null) {
51 query
.setFirstResult(pageNumber
* pageSize
);
55 return (List
<T
>)query
.list();