source: ether_ndacc_bis/persistence/interface/com/ether/dao/DomainAccessObject.java @ 827

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

Changement Jussieu vers Polytechnique

File size: 5.4 KB
Line 
1package com.ether.dao;
2
3import java.io.Serializable;
4import java.util.Collection;
5import java.util.List;
6
7import org.hibernate.SessionFactory;
8import org.hibernate.criterion.DetachedCriteria;
9import org.jetbrains.annotations.NotNull;
10import org.jetbrains.annotations.Nullable;
11
12import com.ether.PersistenceException;
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    /**
119     * Updates persistent object with domain object changes.
120     *
121     * @param domainObject a domain object.
122     */
123    void update( final DO domainObject )
124            throws PersistenceException;
125
126    /**
127     * Updates persistent objects with domain objects changes.
128     *
129     * @param domainObjects domain objects to update.
130     */
131    void updateAll( final Collection<? extends DO> domainObjects )
132            throws PersistenceException;
133
134    /**
135     * Upgrades domain object with persistent objects changes.
136     *
137     * @param domainObject the domain object.
138     */
139    void upgrade( final DO domainObject )
140            throws PersistenceException;
141
142    /**
143     * Upgrades domain objects with persistent objects changes.
144     *
145     * @param domainObjects the domain object.
146     */
147    void upgradeAll( final Collection<DO> domainObjects )
148            throws PersistenceException;
149
150    /**
151     * Deletes the primary key.
152     *
153     * @param primaryKey the primary key.
154     */
155    void deleteByPrimaryKey( final PK primaryKey )
156            throws PersistenceException;
157
158    /**
159     * Deletes an object from persistent storage in the database.
160     *
161     * @param domainObject the domain object.
162     */
163    void delete( final DO domainObject )
164            throws PersistenceException;
165
166    /**
167     * Deletes all domain objects in the database.
168     *
169     * @param domainObjects the domain objects to delete.
170     */
171    void deleteAll( final Collection<DO> domainObjects )
172            throws PersistenceException;
173
174     /**
175     * Sets the session factory.
176     * @param sessionFactory the session factory.
177     */
178    void setSessionFactory( SessionFactory sessionFactory );
179}
Note: See TracBrowser for help on using the repository browser.