source: ether_statistics/persistence/interface/com/ether/dao/DomainAccessObject.java @ 569

Last change on this file since 569 was 569, checked in by vmipsl, 12 years ago

Nouveau projet

File size: 5.7 KB
Line 
1package com.ether.dao;
2
3import com.ether.PersistenceException;
4import com.ether.PersistenceHelper;
5import org.hibernate.SessionFactory;
6import org.hibernate.criterion.DetachedCriteria;
7import org.jetbrains.annotations.NotNull;
8import org.jetbrains.annotations.Nullable;
9
10import java.io.Serializable;
11import java.util.Collection;
12import java.util.List;
13
14public interface DomainAccessObject<DO, PK extends Serializable>
15{
16    /**
17     * @return the domain object class.
18     */
19    Class<DO> getDomainObjectClass();
20
21    /**
22     * Selects an object by criteria.
23     * The result of the select can be an object or any other types in case of projection or a transformed result.
24     *
25     * @param criteria the criteria.
26     * @return the first persistent object that match the criteria.
27     */
28    @Nullable
29    DO selectByCriteria( DetachedCriteria criteria )
30            throws PersistenceException;
31
32    /**
33     * Selects an object by criteria.
34     * The result of the select can be an object or any other types in case of projection or a transformed result.
35     *
36     * @param objectClass the object class.
37     * @param criteria    the criteria.
38     * @return the first persistent object that match the criteria.
39     */
40    @Nullable
41    <O> O selectByCriteria( Class<O> objectClass, DetachedCriteria criteria )
42            throws PersistenceException;
43
44    /**
45     * Selects by criteria. The criteria must created for the object class.
46     * The result of the select can contain an object list or any other types in case of projection or a transformed result.
47     *
48     * @param criteria the criterions.
49     * @return all persistent objects that match the criteria.
50     */
51    @NotNull
52    List<DO> selectAllByCriteria( DetachedCriteria criteria )
53            throws PersistenceException;
54
55    /**
56     * Selects by criteria. The criteria must created for the object class.
57     * The result of the select can contain an object list or any other types in case of projection or a transformed result.
58     *
59     * @param objectClass the object class.
60     * @param criteria    the criterions.
61     * @return all persistent objects that match the criteria.
62     */
63    @NotNull
64    <O> List<O> selectAllByCriteria( Class<O> objectClass, DetachedCriteria criteria )
65            throws PersistenceException;
66
67    /**
68     * Retrieves a domain object that was previously persisted to the database using
69     * the specified primary key.
70     *
71     * @param primaryKey the primary key.
72     * @return the persistent object with the specified primary key. <code>null</code> if not found
73     */
74    @Nullable
75    DO selectByPrimaryKey( @NotNull final PK primaryKey )
76            throws PersistenceException;
77
78    /**
79     * Retrieves a domain object by example.
80     *
81     * @param domainObject the example domain object.
82     * @return a domain object by example.
83     */
84    DO selectByExample( final DO domainObject )
85            throws PersistenceException;
86
87    /**
88     * Retrieves a domain object by example.
89     *
90     * @param domainObject the example domain object.
91     * @return a domain object by example.
92     */
93    List<DO> selectAllByExample( final DO domainObject )
94            throws PersistenceException;
95
96    /**
97     * Returns all persistent objects of type.
98     *
99     * @return all persistent objects of type.
100     * @throws PersistenceException the persistence exception.
101     */
102    List<DO> selectAll()
103            throws PersistenceException;
104
105    /**
106     * Persists a domain object into database and return the object primary key.
107     *
108     * @param domainObject a domain object.
109     * @return the primary key.
110     */
111    @NotNull
112    PK insert( final DO domainObject )
113            throws PersistenceException;
114
115    void insertAll( @NotNull final Collection<DO> domainObjects )
116            throws PersistenceException;
117
118    void insertAllWithUpdate( @NotNull final Collection<DO> domainObjects )
119            throws PersistenceException;
120
121    /**
122     * Updates persistent object with domain object changes.
123     *
124     * @param domainObject a domain object.
125     */
126    void update( final DO domainObject )
127            throws PersistenceException;
128
129    /**
130     * Updates persistent objects with domain objects changes.
131     *
132     * @param domainObjects domain objects to update.
133     */
134    void updateAll( final Collection<? extends DO> domainObjects )
135            throws PersistenceException;
136
137    /**
138     * Upgrades domain object with persistent objects changes.
139     *
140     * @param domainObject the domain object.
141     */
142    void upgrade( final DO domainObject )
143            throws PersistenceException;
144
145    /**
146     * Upgrades domain objects with persistent objects changes.
147     *
148     * @param domainObjects the domain object.
149     */
150    void upgradeAll( final Collection<DO> domainObjects )
151            throws PersistenceException;
152
153    /**
154     * Deletes the primary key.
155     *
156     * @param primaryKey the primary key.
157     */
158    void deleteByPrimaryKey( final PK primaryKey )
159            throws PersistenceException;
160
161    /**
162     * Deletes an object from persistent storage in the database.
163     *
164     * @param domainObject the domain object.
165     */
166    void delete( final DO domainObject )
167            throws PersistenceException;
168
169    /**
170     * Deletes all domain objects in the database.
171     *
172     * @param domainObjects the domain objects to delete.
173     */
174    void deleteAll( final Collection<DO> domainObjects )
175            throws PersistenceException;
176
177    /**
178     * Sets the session factory.
179     *
180     * @param sessionFactory the session factory.
181     */
182    void setSessionFactory( SessionFactory sessionFactory );
183
184    interface Operation<O>
185            extends PersistenceHelper.Operation<O>
186    {
187    }
188}
Note: See TracBrowser for help on using the repository browser.