Revision a784f00f
Added by Katja Luther about 14 years ago
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/hibernate/common/MarkerDaoImpl.java | ||
---|---|---|
9 | 9 |
|
10 | 10 |
package eu.etaxonomy.cdm.persistence.dao.hibernate.common; |
11 | 11 |
|
12 |
import java.util.List; |
|
13 |
|
|
14 |
import org.hibernate.Criteria; |
|
15 |
import org.hibernate.criterion.Projections; |
|
16 |
import org.hibernate.criterion.Restrictions; |
|
12 | 17 |
import org.springframework.stereotype.Repository; |
13 | 18 |
|
14 | 19 |
import eu.etaxonomy.cdm.model.common.Marker; |
20 |
import eu.etaxonomy.cdm.model.common.MarkerType; |
|
15 | 21 |
import eu.etaxonomy.cdm.persistence.dao.common.IMarkerDao; |
22 |
import eu.etaxonomy.cdm.persistence.query.OrderHint; |
|
16 | 23 |
|
17 | 24 |
@Repository |
18 |
public class MarkerDaoImpl extends CdmEntityDaoBase<Marker> implements IMarkerDao {
|
|
25 |
public class MarkerDaoImpl extends VersionableDaoBase<Marker> implements IMarkerDao {
|
|
19 | 26 |
|
20 | 27 |
public MarkerDaoImpl() { |
21 | 28 |
super(Marker.class); |
22 | 29 |
} |
23 | 30 |
|
31 |
public int count(MarkerType markerType) { |
|
32 |
Criteria criteria = getSession().createCriteria(Marker.class); |
|
33 |
criteria.add(Restrictions.eq("markerType", markerType)); |
|
34 |
criteria.setProjection(Projections.rowCount()); |
|
35 |
return (Integer) criteria.uniqueResult(); |
|
36 |
} |
|
37 |
|
|
38 |
public List<Marker> list(MarkerType markerType, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths) { |
|
39 |
Criteria criteria = getSession().createCriteria(Marker.class); |
|
40 |
criteria.add(Restrictions.eq("markerType", markerType)); |
|
41 |
|
|
42 |
if(pageSize != null) { |
|
43 |
criteria.setMaxResults(pageSize); |
|
44 |
if(pageNumber != null) { |
|
45 |
criteria.setFirstResult(pageNumber * pageSize); |
|
46 |
} |
|
47 |
} |
|
48 |
|
|
49 |
addOrder(criteria, orderHints); |
|
50 |
List<Marker> results = (List<Marker>)criteria.list(); |
|
51 |
defaultBeanInitializer.initializeAll(results, propertyPaths); |
|
52 |
return results; |
|
53 |
} |
|
54 |
|
|
24 | 55 |
} |
Also available in: Unified diff
merge cate-development2 branch with trunk