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
.common
;
12 import java
.util
.Collection
;
13 import java
.util
.List
;
15 import java
.util
.UUID
;
17 import org
.springframework
.dao
.DataAccessException
;
19 import eu
.etaxonomy
.cdm
.model
.common
.CdmBase
;
20 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonBase
;
21 import eu
.etaxonomy
.cdm
.persistence
.dao
.BeanInitializer
;
22 import eu
.etaxonomy
.cdm
.persistence
.query
.OrderHint
;
25 * an data access interface that all data access classes implement
28 * @created 02-Nov-2007 19:36:10
30 public interface ICdmEntityDao
<T
extends CdmBase
> {
33 * @param transientObject
35 * @throws DataAccessException
37 public UUID
saveOrUpdate(T transientObject
) throws DataAccessException
;
39 //public UUID saveOrUpdateAll(Collection<T> transientObjects) throws DataAccessException;
42 * @param newOrManagedObject
44 * @throws DataAccessException
46 public UUID
save(T newOrManagedObject
) throws DataAccessException
;
48 public Map
<UUID
, T
> saveAll(Collection
<T
> cdmObjCollection
) throws DataAccessException
;
51 * @param transientObject
53 * @throws DataAccessException
55 public UUID
update(T transientObject
) throws DataAccessException
;
58 * @param persistentObject
60 * @throws DataAccessException
62 public UUID
refresh(T persistentObject
) throws DataAccessException
;
65 * @param persistentObject
67 * @throws DataAccessException
69 public UUID
delete(T persistentObject
) throws DataAccessException
;
72 * Returns a sublist of CdmBase instances stored in the database.
73 * A maximum of 'limit' objects are returned, starting at object with index 'start'.
74 * @param limit the maximum number of entities returned (can be null to return all entities)
77 * @throws DataAccessException
79 public List
<T
> list(Integer limit
, Integer start
) throws DataAccessException
;
82 * Returns a sublist of CdmBase instances stored in the database. A maximum
83 * of 'limit' objects are returned, starting at object with index 'start'.
86 * the maximum number of entities returned (can be null to return
90 * Supports path like <code>orderHints.propertyNames</code> which
91 * include *-to-one properties like createdBy.username or
92 * authorTeam.persistentTitleCache
94 * @throws DataAccessException
96 public <TYPE
extends T
> List
<TYPE
> list(Integer limit
, Integer start
, List
<OrderHint
> orderHints
);
99 * Returns a sublist of CdmBase instances of type <TYPE> stored in the database.
100 * A maximum of 'limit' objects are returned, starting at object with index 'start'.
101 * @param limit the maximum number of entities returned (can be null to return all entities)
104 * @throws DataAccessException
106 public <TYPE
extends T
> List
<TYPE
> list(Class
<TYPE
> type
, Integer limit
, Integer start
) throws DataAccessException
;
109 public List
<T
> rows(String tableName
, int limit
, int start
) throws DataAccessException
;
114 * @throws DataAccessException
116 public T
findById(int id
) throws DataAccessException
;
121 * @throws DataAccessException
123 public T
findByUuid(UUID Uuid
) throws DataAccessException
;
126 * Finds the cdm entity specified by the <code>uuid</code> parameter and
127 * initializes all its *ToOne relations.
132 public T
load(UUID uuid
);
135 * Finds the cdm entity specified by the <code>uuid</code> parameter and
136 * recursively initializes all bean properties given in the
137 * <code>propertyPaths</code> parameter.
139 * For detailed description and examples <b>please refer to:</b>
140 * {@link BeanInitializer#initializeProperties(Object, List)}
145 public T
load(UUID uuid
, List
<String
> propertyPaths
);
150 * @throws DataAccessException
152 public Boolean
exists(UUID uuid
) throws DataAccessException
;
157 * Returns the number of objects of type <TYPE> - which must extend T
162 public <TYPE
extends T
> int count(Class
<TYPE
> clazz
);
165 * FIXME Should this method exist : I would expect flushing of a session to be
166 * something that a DAO should hide?
171 * Convenience method which makes it easy to discover what type of object this DAO returns at runtime
175 public Class
<T
> getType();